import * as React from "react";
import { Form, Row, Col, Input, Button, Modal, DatePicker, Select, Table, InputNumber, ConfigProvider, message, Spin } from 'antd';
import { ColumnProps } from 'antd/es/table';
import * as moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
import { FormComponentProps } from 'antd/lib/form/Form' //获取form表单的interface
import './index.scss';
import { Link } from "react-router-dom";
import zhCN from 'antd/es/locale/zh_CN';

import { useHistory } from 'react-router'

// 导出
import ExportCsv from "../../common/export";


import { CAMLFilter, CAMLCompare, CamlQuery, SPDataType, CamlParam, CamlOrderBy } from './../../config/CAMLHelper';

// 台账合同
import { ListGUID } from '../../config/ListGuid';
import Api from '../../config/api';

import { dynamicsService } from "../../../../../services/services";
import { isHavePermission } from '../../utils/utils'

// 推荐在入口文件全局设置 locale
import 'moment/locale/zh-cn';
import { Item } from "@pnp/sp/items";
moment.locale('zh-cn');
interface DataType {
  key: React.Key;
  number: string;
  name: string;
  handle: string;
  relative: string;
  dependent: string;
  time: string;
}
interface fromdata {
  field: string;
  text: string;
  errorMessage: string;
  required: boolean;
  type: string;
  value: any;
  options: any;
  theType: any;
  header: any;
  conditions: any;
}
const layout = {
  labelCol: {
    span: 9,

  },
  wrapperCol: {
    offset: 0,
    span: 15,
  },
}
const { Option } = Select;
const { RangePicker } = DatePicker;
const dateFormat = 'YYYY/MM/DD';



const data: DataType[] = [];

const fromData: fromdata[] = [
  {
    field: 'bianhao',
    text: '合同编号',
    errorMessage: '请选择日期',
    required: false,
    type: 'bianhao',
    value: null,
    options: [],
    theType: 'bianhao',
    header: "LastAnswerTime",
    conditions: "Eq",
  }, {
    field: 'jobid',
    text: '语言',
    errorMessage: '请输入',
    required: false,
    type: 'char',
    value: '',
    options: [],
    theType: 'Text',
    header: "Language",
    conditions: "Contains",
  }, {
    field: 'chuangjian',
    text: '创建日期',
    errorMessage: '请选择日期',
    required: false,
    type: 'chuangjian',
    value: null,
    options: [],
    theType: 'chuangjian',
    header: "LastAnswerTime",
    conditions: "Eq",
  }, {
    // field: 'nature',
    field: 'customer',
    text: '问题',
    errorMessage: '请选择',
    required: false,
    type: 'select',
    value: undefined,
    options: [],
    theType: 'Number',
    header: "Contractualproblems",
    conditions: "Eq",
  }, {
    field: 'date1',
    text: '法务受理日',
    errorMessage: '请选择日期',
    required: false,
    type: 'date1',
    value: null,
    options: [],
    theType: 'DateTime',
    header: "AcceptTime",
    conditions: "Ge",
  }, {
    field: 'nature',
    text: '合同性质',
    errorMessage: '请选择',
    required: false,
    type: 'select',
    value: undefined,
    options: [],
    theType: 'Number',
    header: "ContractNature",
    conditions: "Eq",
  }, {
    field: 'date',
    text: '法务最后回答日',
    errorMessage: '请选择日期',
    required: false,
    type: 'date',
    value: null,
    options: [],
    theType: 'DateTime',
    header: "LastAnswerTime",
    conditions: "Ge",
  }, {
    field: 'term',
    text: '合同期限',
    errorMessage: '请选择',
    required: false,
    type: 'select',
    value: undefined,
    options: [],
    theType: 'Number',
    header: "ContractDeadline",
    conditions: "Eq",
  }, {
    field: 'mingcheng',
    text: '合同名称',
    errorMessage: '请选择日期',
    required: false,
    type: 'mingcheng',
    value: null,
    options: [],
    theType: 'mingcheng',
    header: "LastAnswerTime",
    conditions: "Contains",
  }, {
    field: 'importance',
    text: '合同重要性',
    errorMessage: '请选择',
    required: false,
    type: 'select',
    value: undefined,
    options: [],
    theType: 'Number',
    header: "ContractSignificance",
    conditions: "Eq",
  }, {
    field: 'username',
    text: '关键词1',
    errorMessage: '请输入',
    required: false,
    type: 'char',
    value: '',
    options: [],
    theType: 'Text',
    header: "Keyword1",
    conditions: "Contains",
  }, {
    field: 'modify',
    text: '合同修改性质',
    errorMessage: '请输入',
    required: false,
    type: 'char',
    value: '',
    options: [],
    theType: 'Text',
    header: "ContactEditNature",
    conditions: "Contains",
  }, {
    field: 'username2',
    text: '关键词2',
    errorMessage: '请输入',
    required: false,
    type: 'char',
    value: '',
    options: [],
    theType: 'Text',
    header: "Keyword2",
    conditions: "Contains",
  }
  // 资质？？？
  , {
    field: 'Qualifications',
    text: '资质',
    errorMessage: '请选择',
    required: false,
    type: 'select',
    value: undefined,
    options: [],
    theType: 'Text',
    header: "Qualifications",
    conditions: "Eq",
  }
  , {
    field: 'Our',
    text: '我方',
    errorMessage: '请选择',
    required: false,
    type: 'selectss',
    value: undefined,
    options: [],
    theType: 'Text',
    header: "Our",
    conditions: "Eq",
  }, {
    field: 'HasReviewOpinion',
    text: '审核意见书',
    errorMessage: '请选择',
    required: false,
    type: 'selects',
    value: undefined,
    options: [{ Title: '有' }, { Title: '无' }],
    theType: 'Text',
    header: "HasReviewOpinion",
    conditions: "Eq",
  }, {
    field: 'xiangduifang',
    text: '相对方',
    errorMessage: '请选择日期',
    required: false,
    type: 'xiangduifang',
    value: null,
    options: [],
    theType: 'xiangduifang',
    header: "LastAnswerTime",
    conditions: "Contains",
  }, {
    field: 'Lawyerreview',
    text: '律师审查',
    errorMessage: '请选择',
    required: false,
    type: 'selectls',
    value: undefined,
    options: [],
    theType: 'Number',
    header: "LawyerReviewID",
    conditions: "Eq",
  }, {
    field: 'relyOn',
    text: '社内依赖者名',
    errorMessage: '请输入',
    required: false,
    type: 'char1',
    value: undefined,
    options: [],
    theType: 'Text',
    header: "RelierName",
    conditions: "Contains",
  }, {
    field: 'number',
    text: '裁决编号',
    errorMessage: '请输入编号',
    required: false,
    type: 'char',
    value: '',
    options: [],
    theType: 'Text',
    header: "RuleNumber",
    conditions: "In",
  },
  {
    field: 'company',
    text: '所属公司',
    errorMessage: '请输入',
    required: false,
    type: 'char',
    value: undefined,
    options: [],
    theType: 'Text',
    header: "BelongsCompany",
    conditions: "Eq",
  }
  // 其他
  , {
    field: 'Other',
    text: '其他',
    errorMessage: '请输入',
    required: false,
    type: 'char',
    value: undefined,
    options: [],
    theType: 'Text',
    header: "Other",
    conditions: "Contains",
  }, {
    field: 'department',
    text: '所属部门',
    errorMessage: '请输入',
    required: false,
    type: 'char',
    value: undefined,
    options: [],
    theType: 'Text',
    header: "BelongsDepartment",
    conditions: "Eq",
  }, {
    field: 'tobear',
    text: '审查担当',
    errorMessage: '请选择',
    required: false,
    type: 'multiSelect',
    value: undefined,
    options: [],
    theType: 'Text',
    header: "ReviewOnID",
    conditions: "Eq",
  }
]


const formItemLayout = {
  labelCol: {
    span: 7,

  },
  wrapperCol: {
    offset: 0,
    span: 17,
  },
}
class SearchExportContract extends React.Component<FormComponentProps> {

  columns: ColumnProps<any>[] = [
    {
      title: '合同编号',
      dataIndex: 'Title',
      key: 'Title',
      align: 'center',
      render: (text, record) => {
        let _this = this
        return (
          
          <div>
            {
              isHavePermission('SearchExportContract/toedit') && <div><Link to={{ pathname: record.Title.split('-').length > 0 && record.Title.split('-')[1] != '0' && !record.Title.includes('DUMY') ? "AddContractVersion" : "AddContractNo", state: { id: text, backPage: 'SearchExportContract' } }}>{text}</Link></div>
            }
            {
              !isHavePermission('SearchExportContract/toedit') && <div style={{color: '#2c93ee',cursor: 'pointer'}} onClick={() => this.toSeeDetails(record)}>{text}</div>
            }
          </div>
        )
      },
    },
    {
      title: '合同名称',
      dataIndex: 'ContractName',
      key: 'ContractName',
      align: 'center',
    },
    {
      title: '法务受理日',
      dataIndex: 'AcceptTime',
      key: 'AcceptTime',
      align: 'center',
      render(text, record: any) {
        if (record.AcceptTime != 'Invalid date') {
          return (
            <div>
              {text}
            </div>
          )
        } else {
          return (<div></div>)
        }
      },
  
    }, {
      title: '相对方',
      dataIndex: 'Counterparty',
      key: 'Counterparty',
      align: 'center',
    },
    {
      title: '社内依赖者名',
      dataIndex: 'RelierName',
      key: 'RelierName',
      align: 'center',
    },
    {
      title: '创建时间',
      dataIndex: 'Created',
      key: 'Created',
      align: 'center',
      // render: text => <div>{text === null ? text : text.slice(0, 10) + ' ' + text.slice(11, 19)}</div>,
  
    },
    {
      title: '创建者',
      dataIndex: 'AuthorName',
      key: 'AuthorName',
      align: 'center',
      // render: text => <div>{text === null ? text : text.slice(0, 10) + ' ' + text.slice(11, 19)}</div>,
  
    }
  ]
  constructor(props: any & FormComponentProps) {
    super(props);
  }
  /**
   * 根据后台返回的 data 中 type 类型生成不同的组件
   * @param item  json
   * @param Component
   */
  switchItem(item) {
    let defaultDateValue = [];
    if(this.state.form.dateOf2 != "" && this.state.form.dateOf3 != null){
      
      defaultDateValue = [
        moment(this.state.form.dateOf2, dateFormat),
        moment(this.state.form.dateOf3, dateFormat),
      ];
    }
    const type = item.type;
    switch (type) {
      case 'Picker':
        return <RangePicker format={dateFormat} placeholder={['选择开始日期', '选择结束日期']} />;
      case 'int':
        return <InputNumber style={{ width: '100%' }} />;
      case 'char':
        return <Input style={{ width: '100%' }} placeholder={item.errorMessage} />;
      case 'char1':
        return <Input allowClear placeholder="请输入内容"
          onChange={(event) => { this.allowClear(event, "community") }}
          onBlur={(event) => { this.loseFocus(event, "community") }} />
      case 'date':
        return <DatePicker format={dateFormat} style={{ width: '100%' }} placeholder={item.errorMessage} />;
      case 'date1':
        return <DatePicker format={dateFormat} style={{ width: '100%' }} placeholder={item.errorMessage} />;
      case 'select':
        return (
          <Select style={{ width: '100%' }} placeholder={item.errorMessage}>
            {
              item.options.map((option, index) => {
                return (<Option value={option.Title} key={option.Title}>{option.Title}</Option>)
              })
            }
          </Select>
        )
      case 'selectls':
        return (
          <Select style={{ width: '100%' }} placeholder={item.errorMessage}>
            {
              item.options.map((option, index) => {
                return (<Option value={option.Id} key={option.Title}>{option.Title}</Option>)
              })
            }
          </Select>
        )
      case 'selects':
        return (
          <Select style={{ width: '100%' }} placeholder={item.errorMessage}>
            {
              item.options.map((option, index) => {
                return (<Option value={option.Title} key={option.Title}>{option.Title}</Option>)
              })
            }
          </Select>
        )
        case 'selectss':
          return (
            <Select style={{ width: '100%' }} placeholder={item.errorMessage}>
              {
                item.options.map((option, index) => {
                  return (<Option value={option} key={option}>{option}</Option>)
                })
              }
            </Select>
          )
      case 'searchThe':
        return (
          <Select
            style={{ width: '100%' }}
            allowClear
            showSearch
            placeholder={item.errorMessage}
            value={item.options}
            onChange={(event, value) => { this.handleSelectChangess(event, value, "community") }}
            optionFilterProp="children"
            filterOption={(input, option: any) => {
              return (Array.isArray(option.props.children) ? option.props.children.join('') : option.props.children).toLowerCase().indexOf(input.toLowerCase()) >= 0
            }}
          >
            {
              item.options.map(element => {
                return <Option value={element.displayName} key={element.companyName}>{element.displayName} 公司:{element.companyName} 部门:{element.department}</Option>
              })
            }
          </Select>
        )

      case 'bianhao':
        return (
          <Input.Group compact>
            <Input style={{ width: '45%', marginRight: 0, textTransform: 'uppercase' }} placeholder="请输入"
              onChange={(event) => { this.change(event, "contract1") }}
              value={this.state.form.contract1} />
            <Input
              className="site-input-split"
              style={{
                width: '10%',
                background: 'white',
                pointerEvents: 'none',
                border: 'none',
              }}
              placeholder="~"
              disabled
            />
            <Input
              className="site-input-right"
              style={{
                width: ' 45%',
              }}
              placeholder="请输入"
              onChange={(event) => { this.change(event, "contract2") }}
              value={this.state.form.contract2}
            />
          </Input.Group>
        )
      case 'chuangjian':
        return (
          <Input.Group compact>
            <RangePicker
              style={{ width: '100%' }}
              onChange={this.onChangeRangeDate1}
              format={"YYYY-MM-DD"}
              defaultValue={defaultDateValue}
              placeholder={['选择开始日期', '选择结束日期']}
            />
          </Input.Group>
        )

      case 'mingcheng':
        return (
          <Input.Group compact>
            <Input
              style={{ width: '100%' }}
              placeholder="请输入"
              onChange={(event) => { this.change(event, "contractName") }}
              value={this.state.form.contractName}
            />
          </Input.Group>
        )
      case 'wofang':
        return (
          <Input.Group compact>
            <Input
              style={{ width: '100%' }}
              placeholder="请输入"
              onChange={(event) => { this.change(event, "min") }}
              value={this.state.form.min}

            />
          </Input.Group>
        )
      case 'xiangduifang':
        return (
          <Input.Group compact>
            <Input
              style={{ width: '100%' }}
              placeholder="请输入"
              value={this.state.form.otherSide}
              onChange={(event) => { this.change(event, "otherSide") }}
            />
          </Input.Group>
        )
      case 'multiSelect':
        return (
          <Select mode='multiple' maxTagCount={1} placeholder={item.errorMessage}>
            {
              item.options.map((option, index) => {
                return (<Option value={option.username} key={option.ID}>{option.username}</Option>)
              })
            }
          </Select>
        )

      default:
        return <Input />;
    }
  }

  // 下拉框改变赋值
  handleSelectChangess(e, v, key) {
    if (v == undefined) {
      fromData[18].value = undefined
      fromData[20].value = undefined
      fromData[22].value = undefined
      return
    }
    fromData[18].value = v.props.children[0]
    fromData[20].value = v.props.children[2]
    fromData[22].value = v.props.children[4]

    return
    this.setState({
      form: {
        ...this.state.form,
        [key]: e,
        company: v.props.children[2],
        //所属部门
        department: v.props.children[4],
      }
    })
  }

  allowClear(e, key) {
    const { value } = e.target;
    if (!value && e.type !== 'change') {
      // do something
      fromData[18].value = undefined
      fromData[20].value = undefined
      fromData[22].value = undefined
    } else {
      fromData[18].value = e.target.value
    }
  }


  loseFocus(e, key) {
    let array = JSON.parse(sessionStorage.getItem('AADUsers'));
    // 
    let size: any = []
    for (let index = 0; index < array.length; index++) {
      if (e.target.value == array[index].displayName) {
        size.push(array[index])
      }
    }
    // 
    if (size.length == 0) {
      fromData[18].value = e.target.value
      fromData[20].value = undefined
      fromData[22].value = undefined
    } else {
      fromData[18].value = size[0].displayName
      fromData[20].value = size[0].companyName
      fromData[22].value = size[0].department
      this.setState({
        ces:'2'
      })
    }
  }

  handleSubmit = (e) => {
    localStorage.removeItem('searchForm'); //删除普通检索的条件缓存
    this.setState({
      loading: true
    })

    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      this.setState({
        loading: true
      })

      if (!err) {
        // 清空选中条件
        // let params: CamlParam[] = [];
        // let params: any = [];
        let params: any = [
          {
            logic: "and",
            where: [
              {
                key: 'ContractStatus',
                filterType: "Eq",
                value: "有效"
              }
            ]
          }
        ];




        for (let i = 0; i < fromData.length; i++) {
          let size = fromData[i].field + ""
          // 是否是 有开始时间结束时间
          let istrue = false
          // 是否是审查担当
          let isReview = false
          if (size == "bianhao") {

            // 在两输入框全部输入执行 查流水号区间
            if (this.state.form.contract1 != null && this.state.form.contract1 != "" && this.state.form.contract2 != null && this.state.form.contract2 != "") {
              // 在输入框1 2 都有值的情况下 判断输入框1值的格式是否正确
              let pattern = /^[A-Za-z]{1}(?![0-9]+$)(?![A-Za-z]+$)[0-9A-Za-z]*(-)?[0-9]*$/;

              let pattern1 = /^[A-Za-z]{1}(?![0-9]+$)(?![A-Za-z]+$)(?![A-Za-z]+$)(?=.*-)(?![0-9]+$)[0-9A-Za-z]*(-)?[0-9]*.*\d$/;


              let number1 = ""
              let number2 = ""
              //
              if (this.state.form.contract1.indexOf("-") != -1) {
                if (pattern1.test(this.state.form.contract1)) {
                  // 输入整加版本号查询
                  // 获取完整加版本号的编号 - 前
                  let numberBefore = this.getCaption(this.state.form.contract1, 0)
                  // 获取完整加版本号的编号 - 后
                  let AfterTheNumber = this.getCaption(this.state.form.contract1, 1)

                  // 截取编号最后三位流水号
                  var str1 = numberBefore.substring(numberBefore.length - 7)
                  // 我方
                  var our = numberBefore.slice(0, -7)
                  // 年份
                  let year = str1.slice(0, 4)
                  // 流水号
                  let serialNumber = str1.substring(str1.length - 3)
                  // 库里面的流水号是 003 004这种 直接转换数字类似去掉00
                  //
                  serialNumber = parseInt(serialNumber)
                  // 查询条件


                  // params[0].where.push({
                  //   key: 'AcceptYear',
                  //   filterType: "Eq",
                  //   value: year
                  // })
                  // params[0].where.push({
                  //   key: 'SerialNum',
                  //   filterType: "Ge",
                  //   value: serialNumber
                  // })
                  // params[0].where.push({
                  //   key: 'VersionNum',
                  //   filterType: "Ge",
                  //   value: AfterTheNumber
                  // })

                  number1 = this.state.form.contract1


                } else {
                  message.warning('合同编号格式有误');
                  this.setState({
                    loading: false,
                    inSearchOf: false,
                  })
                  return
                }
              } else {
                if (pattern.test(this.state.form.contract1)) {
                  // contract1
                  // 截取编号最后三位流水号
                  var str1 = this.state.form.contract1.substring(this.state.form.contract1.length - 7)
                  // 我方
                  var our = this.state.form.contract1.slice(0, -7)
                  // 年份
                  let year = str1.slice(0, 4)
                  // 流水号
                  let serialNumber = str1.substring(str1.length - 3)
                  // 库里面的流水号是 003 004这种 直接转换数字类似去掉00
                  //
                  serialNumber = parseInt(serialNumber)

                  // params.push({
                  //   item1: 'Our',
                  //   item2: 'AcceptYear',
                  //   item3: 'SerialNum',
                  //   text1: our,
                  //   text2: year,
                  //   text3: serialNumber,
                  //   type: "contractNo2"
                  // })
                  // params[0].where.push({
                  //   key: 'Our',
                  //   filterType: "Eq",
                  //   value: our
                  // })
                  // params[0].where.push({
                  //   key: 'AcceptYear',
                  //   filterType: "Eq",
                  //   value: year
                  // })
                  // params[0].where.push({
                  //   key: 'SerialNum',
                  //   filterType: "Ge",
                  //   value: serialNumber
                  // })

                  number1 = this.state.form.contract1

                } else {
                  message.warning('合同编号格式有误');
                  this.setState({
                    loading: false,
                    inSearchOf: false,
                  })
                  return
                }
              }

              if (this.state.form.contract2.indexOf("-") != -1) {
                if (pattern1.test(this.state.form.contract2)) {
                  // params.push(new CamlParam("Title", this.state.form.contract2, SPDataType.Text, CAMLCompare.Contains));
                  // 输入整加版本号查询
                  // 获取完整加版本号的编号 - 前
                  let numberBefore = this.getCaption(this.state.form.contract2, 0)
                  // 获取完整加版本号的编号 - 后
                  let AfterTheNumber = this.getCaption(this.state.form.contract2, 1)

                  //
                  //
                  // 截取编号最后三位流水号
                  var str1 = numberBefore.substring(numberBefore.length - 7)
                  // 我方
                  var our = numberBefore.slice(0, -7)
                  // 年份
                  let year = str1.slice(0, 4)
                  // 流水号
                  let serialNumber = str1.substring(str1.length - 3)
                  // 库里面的流水号是 003 004这种 直接转换数字类似去掉00
                  //
                  serialNumber = parseInt(serialNumber)
                  // 查询条件
                  //  我方
                  // params.push(new CamlParam("Our", our, SPDataType.Text, CAMLCompare.Eq));
                  // 年份
                  // params.push(new CamlParam("AcceptYear", year, SPDataType.Number, CAMLCompare.Eq));
                  // 流水号
                  // params.push(new CamlParam("SerialNum", serialNumber, SPDataType.Number, CAMLCompare.Leq));//大于等于
                  //  版本号
                  // params.push(new CamlParam("VersionNum", AfterTheNumber, SPDataType.Number, CAMLCompare.Leq));//大于等于

                  // params[0].where.push({
                  //   key: 'Our',
                  //   filterType: "Eq",
                  //   value: our
                  // })
                  // params[0].where.push({
                  //   key: 'AcceptYear',
                  //   filterType: "Eq",
                  //   value: year
                  // })
                  // params[0].where.push({
                  //   key: 'SerialNum',
                  //   filterType: "Ge",
                  //   value: serialNumber
                  // })
                  // params[0].where.push({
                  //   key: 'VersionNum',
                  //   filterType: "Ge",
                  //   value: AfterTheNumber
                  // })

                  number2 = this.state.form.contract2

                } else {
                  message.warning('合同编号格式有误');
                  this.setState({
                    loading: false,
                    inSearchOf: false,
                  })
                  return
                }
              } else {
                // 在输入框1 2 都有值的情况下 判断输入框2值的格式是否正确
                if (pattern.test(this.state.form.contract2)) {
                  // contract2
                  var str2 = this.state.form.contract2.substring(this.state.form.contract1.length - 7)
                  let serialNumber2 = str2.substring(str2.length - 3)
                  // 库里面的流水号是 003 004这种 直接转换数字类似去掉00
                  //
                  serialNumber2 = parseInt(serialNumber2)
                  // 流水号
                  // params.push(new CamlParam("SerialNum", serialNumber2, SPDataType.Number, CAMLCompare.Leq));//小于于等于

                  // params[0].where.push({
                  //   key: 'SerialNum',
                  //   filterType: "Le",
                  //   value: serialNumber2
                  // })

                  number2 = this.state.form.contract2


                } else {
                  message.warning('合同编号格式有误');
                  this.setState({
                    loading: false,
                    inSearchOf: false,
                  })
                  return
                }
              }

              params[0].where.push({
                key: '',
                filterType: "ContractNum",
                value: number1 + "|" + number2
              })



            } else if (this.state.form.contract1 != null && this.state.form.contract1 != "") {
              // 如果不满足两个输入框输入条件 判断输入框1是否有值
              let pattern = /^[A-Za-z]{1}(?![0-9]+$)(?![A-Za-z]+$)[0-9A-Za-z]*(-)?[0-9]*$/;
              if (pattern.test(this.state.form.contract1)) {
                // params.push(new CamlParam("Title", this.state.form.contract1, SPDataType.Text, CAMLCompare.Contains));
                // params.push({
                //   item: 'Title',
                //   text: this.state.form.contract1,
                //   type: "indexOf"
                // })

                // params[0].where.push({
                //   key: 'Title',
                //   filterType: "Contains",
                //   value: this.state.form.contract1
                // })
                params[0].where.push({
                  key: '',
                  filterType: "ContractNum",
                  value: this.state.form.contract1
                })

              } else {
                message.warning('合同编号格式有误');
                this.setState({
                  loading: false,
                  inSearchOf: false,
                })
                return
              }
            } else if (this.state.form.contract2 != null && this.state.form.contract2 != "") {
              // 如果不满足两个输入框输入条件 判断输入框1是否有值
              let pattern = /^[A-Za-z]{1}(?![0-9]+$)(?![A-Za-z]+$)[0-9A-Za-z]*(-)?[0-9]*$/;
              if (pattern.test(this.state.form.contract2)) {
                // params.push(new CamlParam("Title", this.state.form.contract2, SPDataType.Text, CAMLCompare.Contains));
                // params.push({
                //   item: 'Title',
                //   text: this.state.form.contract2,
                //   type: "indexOf"
                // })

                // params[0].where.push({
                //   key: 'Title',
                //   filterType: "Contains",
                //   value: this.state.form.contract2
                // })
                params[0].where.push({
                  key: '',
                  filterType: "ContractNum",
                  value: this.state.form.contract2
                })

              } else {
                message.warning('合同编号格式有误');
                this.setState({
                  loading: false
                })
                return
              }
            }


          } else if (size == "mingcheng") {
            // 合同名称
            if (this.state.form.contractName != null && this.state.form.contractName != "") {
              // this.fuzzy("ContractName", this.state.form.contractName, "Text", "", "")
              // params.push(new CamlParam("ContractName", this.state.form.contractName, SPDataType.Text, CAMLCompare.Contains));
              // params.push({
              //   item: 'ContractName',
              //   text: this.state.form.contractName,
              //   type: "test"
              // })
              params[0].where.push({
                key: 'ContractName',
                filterType: "Contains",
                value: this.state.form.contractName
              })
            }
          } else if (size == "wofang") {
            // 我方
            if (this.state.form.min != null && this.state.form.min != "") {
              // this.fuzzy("Our", this.state.form.min, "Text", "", "")
              // params.push(new CamlParam("Our", this.state.form.min, SPDataType.Text, CAMLCompare.Contains));
              params[0].where.push({
                key: 'Our',
                filterType: "Eq",
                value: this.state.form.min
              })
            }
          } else if (size == "xiangduifang") {
            // 相对方
            if (this.state.form.otherSide != null && this.state.form.otherSide != "") {
              // this.fuzzy("Counterparty", this.state.form.otherSide, "Text", "", "")
              // params.push(new CamlParam("Counterparty", this.state.form.otherSide, SPDataType.Text, CAMLCompare.Contains));

              params[0].where.push({
                key: 'Counterparty',
                filterType: "Contains",
                value: this.state.form.otherSide
              })
            }
          } else if (size == "dandang") {
            // 审查担当
            if (this.state.form.list != undefined && this.state.form.list != null && this.state.form.list.length != 0) {
              // this.fuzzy("ReviewOnID", this.state.form.personreview, "Number", "", "")

              // let array = []

              for (let i = 0; i < this.state.form.list.length; i++) {
                // params.push(new CamlParam("ReviewOn", this.state.form.list[i].key, SPDataType.Text, CAMLCompare.Contains));
                // array.push(this.state.form.list[i].key)
                params[0].where.push({
                  key: 'ReviewOnID',
                  filterType: "Contains",
                  value: this.state.form.list[i].key
                })
              }

              // params.push({
              //   item: 'ReviewOn',
              //   text: array,
              //   type: "queryId"
              // })
              // params[0].where.push({
              //   key: 'ReviewOnID',
              //   filterType: "Contains",
              //   value: this.state.form.list[i].key
              // })
              // params.push(new CamlParam("ReviewOnID", this.state.form.personreview, SPDataType.Number, CAMLCompare.Eq));
            }
          } else if (size == "chuangjian") {
            if (this.state.form.dateOf2 != "" && this.state.form.dateOf2 != null) {
              // 2022-10-20T00:00:00Z
              let size = this.state.form.dateOf2
              let size1 = this.state.form.dateOf3
              // params.push(new CamlParam("Created", size, SPDataType.DateTime, CAMLCompare.Geq));//我这里用的大于等于，你根据你实际情况来
              // params.push({
              //   item: 'Created',
              //   text: data,
              //   item1: 'Created',
              //   text1: data1,
              //   type: "startEnd"
              // })
              params[0].where.push({
                key: 'Created',
                filterType: "Ge",
                value: size
              })
              params[0].where.push({
                key: 'Created',
                filterType: "Le",
                value: size1
              })
            }

            //结束日期
            // if (this.state.form.dateOf3 != "" && this.state.form.dateOf3 != null) {
            //   let size = this.state.form.dateOf3
            //   params.push(new CamlParam("Created", size, SPDataType.DateTime, CAMLCompare.Leq));//我这里用的小于于等于，你根据你实际情况来
            // }
          } else {
            if (size == "date" && values.date != null && values.date != undefined && values.date != "") {
              values.date = moment(values.date).format('YYYY-MM-DD')
              values.date = values.date
            }
            if (size == "date1" && values.date1 != null && values.date1 != undefined && values.date1 != "") {
              values.date1 = moment(values.date1).format('YYYY-MM-DD')
              values.date1 = values.date1
            }

            // 审查担当
            if (size == "tobear" && values.tobear != null && values.tobear != undefined && values.tobear != "") {
              isReview = true
            }

            if (size == "Legalacceptancedate" && values.Legalacceptancedate != null && values.Legalacceptancedate != undefined && values.Legalacceptancedate != "") {
              values.Legalacceptancedate[0] = moment(values.Legalacceptancedate[0]).format('YYYY-MM-DD')
              values.Legalacceptancedate[0] = values.Legalacceptancedate[0]

              values.Legalacceptancedate[1] = moment(values.Legalacceptancedate[1]).format('YYYY-MM-DD')
              values.Legalacceptancedate[1] = values.Legalacceptancedate[1]
              istrue = true
              // moment(values.Legalacceptancedate).format('YYYY-MM-DD')
              // values.Legalacceptancedate = values.Legalacceptancedate
            }

            if (values[`${size}`] != null && values[`${size}`] != undefined && values[`${size}`] != "") {
              if (!istrue) {
                // 判断是否是多选框 审查担当
                if (isReview) {
                  // let array = []

                  for (let i = 0; i < values.tobear.length; i++) {
                    // array.push(values.tobear[i])
                    params[0].where.push({
                      key: 'ReviewOnID',
                      filterType: "Contains",
                      value: values.tobear[i].replace("-历史", "")
                    })
                  }

                  // params.push({
                  //   item: 'ReviewOnID',
                  //   text: array,
                  //   type: "queryId"
                  // })

                  isReview = false
                } else {
                  // params.push(new CamlParam(fromData[i].header, values[`${size}`], SPDataType[`${fromData[i].theType}`], CAMLCompare[`${fromData[i].conditions}`]));
                  // params.push({
                  //   item: fromData[i].header,
                  //   text: values[`${size}`],
                  //   type: "indexOf"
                  // })

                  params[0].where.push({
                    key: fromData[i].header,
                    filterType: fromData[i].conditions,
                    value: values[`${size}`]
                  })
                }
              } else {
                // params.push(new CamlParam(fromData[i].header, values.Legalacceptancedate[0], SPDataType.DateTime, CAMLCompare.Geq));
                // params.push(new CamlParam(fromData[i].header, values.Legalacceptancedate[1], SPDataType.DateTime, CAMLCompare.Leq));
                // params.push({
                //   item: fromData[i].header,
                //   text: values.Legalacceptancedate[0],
                //   item1: fromData[i].header,
                //   text1: values.Legalacceptancedate[1],
                //   type: "startEnd"
                // })
                params[0].where.push({
                  key: fromData[i].header,
                  filterType: "Ge",
                  value: values.Legalacceptancedate[0]
                })
                params[0].where.push({
                  key: fromData[i].header,
                  filterType: "Le",
                  value: values.Legalacceptancedate[1]
                })
                istrue = false
              }

            }
          }
        }

        // 检索
        
        localStorage.setItem('searchFormParams', JSON.stringify(params)); //缓存高级检索item
        this.theQuery(params);
        fromData[18].value = undefined
        fromData[20].value = undefined
        fromData[22].value = undefined
        // this.state.form.dateOf2 = ""
        // this.state.form.dateOf3 = ""
        // 关闭弹窗
        this.setParamsByCache(params[0].where); //赋值高级检索弹框params
        this.setState({
          visible: false,
          confirmLoading: false,
        });
      }
    });
  }
  list = ['测试数据', '测试数据1'];
  state = {
    ExportCsvVisible: false,
    ces:'',
    exportData: {
      filename: '合同导出',//文件名称
      parentElName: 'Button_2',//父元素类名
      elClassName: 'custom',//当前点击元素类名
      dowloadText: '导出CSV',
      isLoading: true,
      headers: [//表头 key 对应data的属性
        { label: "合同编号", key: "Title" },
        { label: "法务受理日", key: "AcceptTime" },
        { label: "法务最后回答日", key: "LastAnswerTime" },
        { label: "合同名称", key: "ContractName" },
        { label: "关键词1", key: "Keyword1" },
        { label: "关键词2", key: "Keyword2" },
        { label: "我方", key: "Our" },
        { label: "相对方", key: "Counterparty" },
        { label: "社内依赖者名", key: "RelierName" },
        { label: "所属公司", key: "BelongsCompany" },
        { label: "所属部门", key: "BelongsDepartment" },
        { label: "语言", key: "Language" },
        { label: "问题", key: "Contractualproblems" },
        { label: "合同性质", key: "ContractNature" },
        { label: "合同期限", key: "ContractDeadline" },
        { label: "合同重要性", key: "ContractSignificance" },
        { label: "合同修改性质", key: "ContactEditNature" },
        { label: "资质", key: "Qualifications" },
        { label: "审核意见书", key: "HasReviewOpinion" },
        { label: "律师审查", key: "ContractLawyerReview" },
        { label: "决裁编号", key: "RuleNumber" },
        { label: "文件保存", key: "FileAddress" },
        { label: "其它", key: "Other" },
        { label: "审查担当", key: "ReviewOnID" },
        { label: "创建者", key: "AuthorName" },
        { label: "创建时间", key: "Created" },
      ],
      data: [//数据源
      ]
    },
    seeDetailsVisible: false,
    reviewOnxuan: [],
    detailform: {
      Title: null, //合同编号
      AcceptTime: null,//法务受理日
      Language: null,//语言
      Problem: null,//问题
      LastAnswerTime: null,//法务最后回答
      ContractNatureID: [],//合同性质
      ContractName: null,//合同名称
      ContractDeadlineID:  [],//合同期限
      Keyword1: null,//关键1
      ContractSignificanceID: [],//合同重要性
      Keyword2: null,//关键2
      ContactEditNature: [],//合同修改性质
      Persons: [], //我方
      Qualifications: [],//资质
      Counterparty: null,//相对方
      LawyerReviewID: [],//律师审查 
      RelierName: null,//社内依赖者
      BelongsCompany: null,//所属公司
      ReviewOnID: [],//审查担当
      BelongsDepartment: null,//所属部门
      FileAddress: null,//文件保存路径
      Other: null,//其它
      HasReviewOpinion: null,//申请书 
      reviewOnxuan: null,
      RuleNumber: null,
      Our: null,
    },
    problemList: [],
    natureList: [],
    termList: [],
    importanceList: [],
    modificationList: [],
    qualificationsList: [],
    LawyerList: [],

    filter: [],
    pager: {
      current: 1,
      size: 10
    },
    loading: false,
    inSearchOf: false,
    local: zhCN,
    arr: '',
    // 记录条件个数
    arrSize: 0,
    data: [],
    allData: [],
    size: '',
    // 总数据
    totalnumber: [],
    // 总数据数
    totalnum: 0,
    //表单数据对象
    retrieveList: [],
    form: {
      year: null,
      month: null,
      rangeTime: [],
      time: [],
      // 合同编号1
      contract1: null,
      // 合同编号2
      contract2: null,
      // 创建日期
      dateOf: "",
      // 结束时间
      dateOf1: "",
      dateOf2: "",
      // 结束时间
      dateOf3: "",
      // 合同名称
      contractName: null,
      // 我方
      min: undefined,
      // 相对方
      otherSide: null,
      // 审查担当
      personreview: undefined,
      list: [],
    },
    visible: false,
    confirmLoading: false,
    //审查担当
    personreviewList: [],
    weList: [],
  }
  
  //动态更新绑定数据
  public async componentDidMount() {
    // this.exportData.headers = [
    //   { label: "合同编号", key: "Title" },
    //   { label: "法务受理日", key: "AcceptTime" },
    //   { label: "法务最后回答日", key: "LastAnswerTime" },
    //   { label: "合同名称", key: "ContractName" },
    //   { label: "关键词1", key: "Keyword1" },
    //   { label: "关键词2", key: "Keyword2" },
    //   { label: "我方", key: "Our" },
    //   { label: "相对方", key: "Counterparty" },
    //   { label: "社内依赖者名", key: "RelierName" },
    //   { label: "所属公司", key: "BelongsCompany" },
    //   { label: "所属部门", key: "BelongsDepartment" },
    //   { label: "语言", key: "Language" },
    //   { label: "问题", key: "Contractualproblems" },
    //   { label: "合同性质", key: "ContractNature" },
    //   { label: "合同期限", key: "ContractDeadline" },
    //   { label: "合同重要性", key: "ContractSignificance" },
    //   { label: "合同修改性质", key: "ContactEditNature" },
    //   { label: "资质", key: "Qualifications" },
    //   { label: "审核意见书", key: "HasReviewOpinion" },
    //   { label: "律师审查", key: "ContractLawyerReview" },
    //   { label: "决裁编号", key: "RuleNumber" },
    //   { label: "文件保存", key: "FileAddress" },
    //   { label: "其它", key: "Other" },
    //   { label: "审查担当", key: "ReviewOnID" },
    //   { label: "创建者", key: "Author" },
    //   { label: "创建时间", key: "Created" },
    // ],

    let isBack:any;
    isBack = this.props;

    
    // 

    if (isBack.location.state != undefined) {
      let form = JSON.parse(localStorage.getItem('searchForm')); //检索编号
      let formParams = JSON.parse(localStorage.getItem('searchFormParams')); //高级检索
      let PageIndex = JSON.parse(localStorage.getItem('PageIndex')); // 页码
      let searchType = localStorage.getItem('searchType'); // 检索类型
      let pager = this.state.pager;
      pager.current = PageIndex;
      this.setState(pager);

      
      
      
      
      if(form != null){
        this.setState({form},()=>{
          if (searchType != '无文件') {
            this.retrieve(searchType, 1);
          }else if(searchType == '无文件'){
            this.noFile(1);
          }
          // localStorage.removeItem('searchForm');
        });
      }else if(formParams != null){
        let params = formParams[0].where;
        this.setParamsByCache(params); //高级检索缓存赋值
        this.theQuery(formParams, 1);
      }else{
        this.getData();
      }
      // this.setState({ form })
    }else{
      localStorage.removeItem('searchForm');
      localStorage.removeItem('searchType');
      localStorage.removeItem('searchFormParams');

      fromData.forEach((item, index)=>{
        fromData[index].value = undefined
      })
      
      this.getData();
    }

    this.getTest();// 测试代码，调试API使用
    let token = await dynamicsService.getToken()
    //
    // let getlist = await dynamicsService.getusers(token.data.data)
    // fromData[18].options = getlist.value

  }

  setParamsByCache(params:any) {
    let form = this.state.form;

    fromData.forEach((item, index)=>{
      fromData[index].value = undefined
    })

    params.forEach(function(item, index) {
      let key = item.key;
      let type = item.filterType;
      let value = item.value;
      for(let i = 0; i < fromData.length; i++){
        let field = fromData[i].field;
        if(key == '' && type == 'ContractNum'){ //合同编号
          if (value.indexOf('|') > -1) {
            let num = value.split('|');
            form.contract1 = num[0];
            form.contract2 = num[1];
          }else{
            form.contract1 = value;
          }
          
        }else if(key == 'Language' && field == 'jobid'){ //语言
          fromData[i].value = value;
        }else if(key == 'Created' && type == 'Ge'){ //创建时间
          form.dateOf2 = value;
        }else if(key == 'Created' && type == 'Le'){ //创建时间
          form.dateOf3 = value;
        }else if(key == 'Contractualproblems' && field == 'customer'){ //问题
          fromData[i].value = value;
        }else if(key == 'AcceptTime' && field == 'date1'){ //法务受理日
          fromData[i].value = moment(value, "YYYY-MM-DD")
        }else if(key == 'ContractNature' && field == 'nature'){ //合同性质
          fromData[i].value = value;
        }else if(key == 'LastAnswerTime' && field == 'date'){ //法务最后回答日
          fromData[i].value = moment(value, "YYYY-MM-DD")
        }else if(key == 'ContractDeadline' && field == 'term'){ //合同期限
          fromData[i].value = value;
        }else if(key == 'ContractName' && field == 'mingcheng' && type == 'Contains'){ //合同名称
          form.contractName = value;
        }else if(key == 'ContractSignificance' && field == 'importance' && type == 'Eq'){ //合同重要性              
          fromData[i].value = value;
        }else if(key == 'Keyword1' && field == 'username'){ //关键词1
          fromData[i].value = value;
        }else if(key == 'ContactEditNature' && field == 'modify'){ //合同修改性质
          fromData[i].value = value;
        }else if(key == 'Keyword2' && field == 'username2'){ //关键词2
          fromData[i].value = value;
        }else if(key == 'Qualifications' && field == 'Qualifications'){ //资质
          fromData[i].value = value;
        }else if(key == 'Our' && field == 'Our'){ //我方
          fromData[i].value = value;
        }else if(key == 'HasReviewOpinion' && field == 'HasReviewOpinion'){ //审核申请书
          fromData[i].value = value;
        }else if(key == 'Counterparty' && field == 'xiangduifang'){ //相对方
          form.otherSide = value;
        }else if(key == 'LawyerReviewID' && field == 'Lawyerreview'){ //律师审查
          fromData[i].value = value;
        }else if(key == 'RelierName' && field == 'relyOn'){ //社内依赖者名
          fromData[i].value = value;
        }else if(key == 'RuleNumber' && field == 'number'){ //决裁号
          fromData[i].value = value;
        }else if(key == 'BelongsCompany' && field == 'company'){ //所属公司
          fromData[i].value = value;
        }else if(key == 'Other' && field == 'Other'){ //其他
          fromData[i].value = value;
        }else if(key == 'BelongsDepartment' && field == 'department'){ //所属部门
          fromData[i].value = value;
        }else if(key == 'ReviewOnID' && field == 'tobear'){ //审查担当
          let valArr = [];
          valArr = value.split(';');
          fromData[i].value = valArr;
        }
      }
    });
    this.setState({form},()=>{
      
      
    });
  }

  onChange = (e, key) => {
    this.setState({
      form: {
        ...this.state.form,
        [key]: e
      }
    })
  }
  toSeeDetails = (item:any) => {
    
    let reviewOnxuan = []
    if (item && item.ReviewOnID != null) {
      if (item.ReviewOnID.indexOf(';') != -1) {
        let arrays = item.ReviewOnID.split(';')
        for (let i = 0; arrays.length > i; i++) {
          reviewOnxuan.push(arrays[i].split('#')[1])
        }
      } else {
        reviewOnxuan.push(item.ReviewOnID.split('#')[1])
      }
    }
    item.AcceptTime = !item.AcceptTime ? null : moment(item.AcceptTime).format('YYYY/MM/DD')
    item.LastAnswerTime = !item.LastAnswerTime ? null : moment(item.LastAnswerTime).format('YYYY/MM/DD')
    item.ContactEditNature = !item.ContactEditNature ? [] : item.ContactEditNature.split(';')
    item.reviewOnxuan = reviewOnxuan.toString()
    
    this.setState({
      seeDetailsVisible: true,
      detailform: item,
    })
  }
  detailsClose = () => {
    this.setState({
      seeDetailsVisible: false,
      detailform: {
        Title: null, //合同编号
        AcceptTime: null,//法务受理日
        Language: null,//语言
        Problem: null,//问题
        LastAnswerTime: null,//法务最后回答
        ContractNatureID: [],//合同性质
        ContractName: null,//合同名称
        ContractDeadlineID:  [],//合同期限
        Keyword1: null,//关键1
        ContractSignificanceID: [],//合同重要性
        Keyword2: null,//关键2
        ContactEditNature: [],//合同修改性质
        Persons: [], //我方
        Qualifications: [],//资质
        Counterparty: null,//相对方
        LawyerReviewID: [],//律师审查 
        RelierName: null,//社内依赖者
        BelongsCompany: null,//所属公司
        ReviewOnID: [],//审查担当
        BelongsDepartment: null,//所属部门
        FileAddress: null,//文件保存路径
        Other: null,//其它
        HasReviewOpinion: null,//申请书 
        reviewOnxuan: [],
        RuleNumber: null,
        Our: [],
      },
    })
  }
  // 下拉框改变赋值
  handleSelectChange = (e, key) => {
    this.setState({
      form: {
        key: e,
        ...this.state.form,
        [key]: e
      }
    })
  }
  // 高级检索按钮
  advanced = () => {
    this.setState({
      visible: true,
    });
  }

  // str 微软官方字段  str1 本地字段
  together(str, str1) {
    if (this.state.arr == "") {
      this.state.arr += `${str} eq '${str1}'`
    } else {
      this.state.arr += `and ${str} eq '${str1}'`
    }
  }

  // str 微软官方字段  str1 本地字段 -- 模糊精确搜索
  fuzzy(name, str, type, name1, str1) {
    let arr = [
      {
        title: `${name}`,
        text: `${str}`,
        type: `${type}`,
        title1: `${name1}`,
        text1: `${str1}`
      }
    ]
    this.state.retrieveList.push(arr[0])
  }

  ContentToEmpty = () => {
    this.state.form.personreview = undefined
    this.state.form.list = []
    this.state.form.otherSide = ""
    this.state.form.min = ""
    this.state.form.contractName = ""
    this.state.form.contract1 = ""
    this.state.form.contract2 = ""
    this.state.form.dateOf = ""
    this.state.form.dateOf1 = ""
    this.props.form.resetFields();
  }

  getCaption = (obj, state) => {
    var index = obj.lastIndexOf("\-");
    if (state == 0) {
      obj = obj.substring(0, index);
    } else {
      obj = obj.substring(index + 1, obj.length);
    }
    return obj;
  }
  getCaption2 = (obj, state) => {
    var index = obj.lastIndexOf("\#");
    if (state == 0) {
      obj = obj.substring(0, index);
    } else {
      obj = obj.substring(index + 1, obj.length);
    }
    return obj;
  }

  //无文件检索 
  noFile = (isBack = 0) => {
    // 
    
    // localStorage.setItem('searchForm', JSON.stringify(this.state.form));
    localStorage.setItem('searchType', '无文件')
    this.setState({
      loading: true
    })
    // 清空检索内容
    // this.ContentToEmpty()
    // 清空选中条件
    // let params: CamlParam[] = [];
    let params: any = [
      {
        logic: "and",
        where: [
          {
            key: 'ContractStatus',
            filterType: "Eq",
            value: "有效"
          }
        ]
      }
    ];

    // (file[jay].FSObjType == 1 && file[jay].FileRef.indexOf(element.FileAddress) != -1 && file[jay].Folder.ItemCount == 0
    // params[0].where.push({
    //   key: 'FSObjType',
    //   filterType: "Eq",
    //   value: 1
    // })

    // params[0].where.push({
    //   key: 'FileRef',
    //   filterType: "Eq",
    //   value: ""
    // })

    // params[0].where.push({
    //   key: 'Folder_ItemCount',
    //   filterType: "Eq",
    //   value: 0
    // })
    params[0].where.push({
      key: '',
      filterType: "EmptyFolder",
      value: 1
    })
    
    if ((this.state.form.list != undefined && this.state.form.list != null && this.state.form.list.length != 0) || (this.state.form.personreview != undefined && this.state.form.personreview != null && this.state.form.personreview.length != 0)) {
      params[0].where.push({
        key: 'ReviewOnID',
        filterType: "MultiUsers",
        value: this.state.form.personreview.map(i => i.replace("-历史", "")).join(';')
      })
    }

    localStorage.removeItem('searchFormParams'); //删除高级检索的条件缓存
    let form = this.state.form;
      // 
    
    
    if (form.personreview == undefined) {
      localStorage.setItem('searchForm', JSON.stringify(form));
    }else{
      // localStorage.setItem('searchFormList', JSON.stringify(form.list));
      form.list = [];
      localStorage.setItem('searchForm', JSON.stringify(form));
    }

    this.theQuery(params, isBack)
  }

  // 检索合同按钮
  retrieve = (text, isBack = 0) => {
    
    localStorage.setItem('searchType', text)
    if (this.state.inSearchOf) {
      message.warning('检索中');
      return
    }

    this.setState({
      loading: true,
      inSearchOf: true
    })
    // 清空选中条件
    // let params: CamlParam[] = [];
    let params: any = [
      {
        logic: "and",
        where: [

        ]
      }
    ];



    // test 1.检索  2.废弃  3.申请书  4.合同文件
    if (text == "检索") {
      // 是否检索废弃
      // params.push(new CamlParam("ContractStatus", "有效", SPDataType.Text, CAMLCompare.Eq));
      localStorage.removeItem('searchFormParams'); //删除高级检索的条件缓存
      params[0].where.push({
        key: 'ContractStatus',
        filterType: "Eq",
        value: "有效"
      })
    }
    if (text == "废弃") {
      // 是否检索废弃
      // params.push(new CamlParam("ContractStatus", "废弃", SPDataType.Text, CAMLCompare.Eq));
      params[0].where.push({
        key: 'ContractStatus',
        filterType: "Eq",
        value: "废弃"
      })
      // 清空检索内容
      this.ContentToEmpty()
    }

    // if (text == "无文件检索") {
    //   // 清空检索内容
    //   this.ContentToEmpty()
    // }

    if (text == "草稿") {
      // 是否检索废弃
      // params.push(new CamlParam("ContractStatus", "草稿", SPDataType.Text, CAMLCompare.Eq));
      // params.push({
      //   item: 'ContractStatus',
      //   text: "草稿",
      //   type: "title"
      // })
      const user = JSON.parse(sessionStorage.getItem('userInfo'))
      params[0].where.push({
        key: 'ContractStatus',
        filterType: "Eq",
        value: "草稿"
      }, {
        key: 'AuthorId',
        filterType: "Eq",
        value: user.Id
      })
      // 清空检索内容
      this.ContentToEmpty()
    }
    if (text == "申请书") {
      // 跳转合同申请书文件检索
      location.href = `#/SearchExportFile`
      return
    }
    if (text == "合同文件") {
      // 跳转合同文件检索
      location.href = `#/SearchContract`
      return
    }

    // 相对方
    if (this.state.form.otherSide != null && this.state.form.otherSide != "") {
      // this.fuzzy("Counterparty", this.state.form.otherSide, "Text", "", "")
      // params.push(new CamlParam("Counterparty", this.state.form.otherSide, SPDataType.Text, CAMLCompare.Contains));
      // params.push({
      //   item: 'Counterparty',
      //   text: this.state.form.otherSide,
      //   type: "indexOf"
      // })
      params[0].where.push({
        key: 'Counterparty',
        filterType: "Contains",
        value: this.state.form.otherSide
      })
    }
    // 合同名称
    if (this.state.form.contractName != null && this.state.form.contractName != "") {
      // this.fuzzy("ContractName", this.state.form.contractName, "Text", "", "")
      // params.push(new CamlParam("ContractName", this.state.form.contractName, SPDataType.Text, CAMLCompare.Contains));
      // params.push({
      //   item: 'ContractName',
      //   text: this.state.form.contractName,
      //   type: "test"
      // })
      params[0].where.push({
        key: 'ContractName',
        filterType: "Contains",
        value: this.state.form.contractName
      })
    }
    // 我方
    if (this.state.form.min != null && this.state.form.min != "") {
      // this.fuzzy("Our", this.state.form.min, "Text", "", "")
      // params.push(new CamlParam("Our", this.state.form.min, SPDataType.Text, CAMLCompare.Eq));
      // params.push({
      //   item: 'Our',
      //   text: this.state.form.min,
      //   type: "test"
      // })
      params[0].where.push({
        key: 'Our',
        filterType: "Eq",
        value: this.state.form.min
      })
    }

    // 判断合同编号1 合同编号2 是否 都有值 

    // 在两输入框全部输入执行 查流水号区间
    if (this.state.form.contract1 != null && this.state.form.contract1 != "" && this.state.form.contract2 != null && this.state.form.contract2 != "") {
      // 在输入框1 2 都有值的情况下 判断输入框1值的格式是否正确
      let pattern = /^[A-Za-z]{1}(?![0-9]+$)(?![A-Za-z]+$)[0-9A-Za-z]*(-)?[0-9]*$/;

      let pattern1 = /^[A-Za-z]{1}(?![0-9]+$)(?![A-Za-z]+$)(?![A-Za-z]+$)(?=.*-)(?![0-9]+$)[0-9A-Za-z]*(-)?[0-9]*.*\d$/;


      let number1 = ""
      let number2 = ""
      //
      if (this.state.form.contract1.indexOf("-") != -1) {
        if (pattern1.test(this.state.form.contract1)) {
          // 输入整加版本号查询
          // 获取完整加版本号的编号 - 前
          let numberBefore = this.getCaption(this.state.form.contract1, 0)
          // 获取完整加版本号的编号 - 后
          let AfterTheNumber = this.getCaption(this.state.form.contract1, 1)

          // 截取编号最后三位流水号
          var str1 = numberBefore.substring(numberBefore.length - 7)
          // 我方
          var our = numberBefore.slice(0, -7)
          // 年份
          let year = str1.slice(0, 4)
          // 流水号
          let serialNumber = str1.substring(str1.length - 3)
          // 库里面的流水号是 003 004这种 直接转换数字类似去掉00
          //
          serialNumber = parseInt(serialNumber)
          // 查询条件


          // params[0].where.push({
          //   key: 'AcceptYear',
          //   filterType: "Eq",
          //   value: year
          // })
          // params[0].where.push({
          //   key: 'SerialNum',
          //   filterType: "Ge",
          //   value: serialNumber
          // })
          // params[0].where.push({
          //   key: 'VersionNum',
          //   filterType: "Ge",
          //   value: AfterTheNumber
          // })

          number1 = this.state.form.contract1


        } else {
          message.warning('合同编号格式有误');
          this.setState({
            loading: false,
            inSearchOf: false,
          })
          return
        }
      } else {
        if (pattern.test(this.state.form.contract1)) {
          // contract1
          // 截取编号最后三位流水号
          var str1 = this.state.form.contract1.substring(this.state.form.contract1.length - 7)
          // 我方
          var our = this.state.form.contract1.slice(0, -7)
          // 年份
          let year = str1.slice(0, 4)
          // 流水号
          let serialNumber = str1.substring(str1.length - 3)
          // 库里面的流水号是 003 004这种 直接转换数字类似去掉00
          //
          serialNumber = parseInt(serialNumber)

          // params.push({
          //   item1: 'Our',
          //   item2: 'AcceptYear',
          //   item3: 'SerialNum',
          //   text1: our,
          //   text2: year,
          //   text3: serialNumber,
          //   type: "contractNo2"
          // })
          // params[0].where.push({
          //   key: 'Our',
          //   filterType: "Eq",
          //   value: our
          // })
          // params[0].where.push({
          //   key: 'AcceptYear',
          //   filterType: "Eq",
          //   value: year
          // })
          // params[0].where.push({
          //   key: 'SerialNum',
          //   filterType: "Ge",
          //   value: serialNumber
          // })

          number1 = this.state.form.contract1

        } else {
          message.warning('合同编号格式有误');
          this.setState({
            loading: false,
            inSearchOf: false,
          })
          return
        }
      }

      if (this.state.form.contract2.indexOf("-") != -1) {
        if (pattern1.test(this.state.form.contract2)) {
          // params.push(new CamlParam("Title", this.state.form.contract2, SPDataType.Text, CAMLCompare.Contains));
          // 输入整加版本号查询
          // 获取完整加版本号的编号 - 前
          let numberBefore = this.getCaption(this.state.form.contract2, 0)
          // 获取完整加版本号的编号 - 后
          let AfterTheNumber = this.getCaption(this.state.form.contract2, 1)

          //
          //
          // 截取编号最后三位流水号
          var str1 = numberBefore.substring(numberBefore.length - 7)
          // 我方
          var our = numberBefore.slice(0, -7)
          // 年份
          let year = str1.slice(0, 4)
          // 流水号
          let serialNumber = str1.substring(str1.length - 3)
          // 库里面的流水号是 003 004这种 直接转换数字类似去掉00
          //
          serialNumber = parseInt(serialNumber)
          // 查询条件
          //  我方
          // params.push(new CamlParam("Our", our, SPDataType.Text, CAMLCompare.Eq));
          // 年份
          // params.push(new CamlParam("AcceptYear", year, SPDataType.Number, CAMLCompare.Eq));
          // 流水号
          // params.push(new CamlParam("SerialNum", serialNumber, SPDataType.Number, CAMLCompare.Leq));//大于等于
          //  版本号
          // params.push(new CamlParam("VersionNum", AfterTheNumber, SPDataType.Number, CAMLCompare.Leq));//大于等于

          // params[0].where.push({
          //   key: 'Our',
          //   filterType: "Eq",
          //   value: our
          // })
          // params[0].where.push({
          //   key: 'AcceptYear',
          //   filterType: "Eq",
          //   value: year
          // })
          // params[0].where.push({
          //   key: 'SerialNum',
          //   filterType: "Ge",
          //   value: serialNumber
          // })
          // params[0].where.push({
          //   key: 'VersionNum',
          //   filterType: "Ge",
          //   value: AfterTheNumber
          // })

          number2 = this.state.form.contract2

        } else {
          message.warning('合同编号格式有误');
          this.setState({
            loading: false,
            inSearchOf: false,
          })
          return
        }
      } else {
        // 在输入框1 2 都有值的情况下 判断输入框2值的格式是否正确
        if (pattern.test(this.state.form.contract2)) {
          // contract2
          var str2 = this.state.form.contract2.substring(this.state.form.contract1.length - 7)
          let serialNumber2 = str2.substring(str2.length - 3)
          // 库里面的流水号是 003 004这种 直接转换数字类似去掉00
          //
          serialNumber2 = parseInt(serialNumber2)
          // 流水号
          // params.push(new CamlParam("SerialNum", serialNumber2, SPDataType.Number, CAMLCompare.Leq));//小于于等于

          // params[0].where.push({
          //   key: 'SerialNum',
          //   filterType: "Le",
          //   value: serialNumber2
          // })

          number2 = this.state.form.contract2


        } else {
          message.warning('合同编号格式有误');
          this.setState({
            loading: false,
            inSearchOf: false,
          })
          return
        }
      }

      params[0].where.push({
        key: '',
        filterType: "ContractNum",
        value: number1 + "|" + number2
      })



    } else if (this.state.form.contract1 != null && this.state.form.contract1 != "") {
      // 如果不满足两个输入框输入条件 判断输入框1是否有值
      let pattern = /^[A-Za-z]{1}(?![0-9]+$)(?![A-Za-z]+$)[0-9A-Za-z]*(-)?[0-9]*$/;
      if (pattern.test(this.state.form.contract1)) {
        // params.push(new CamlParam("Title", this.state.form.contract1, SPDataType.Text, CAMLCompare.Contains));
        // params.push({
        //   item: 'Title',
        //   text: this.state.form.contract1,
        //   type: "indexOf"
        // })

        // params[0].where.push({
        //   key: 'Title',
        //   filterType: "Contains",
        //   value: this.state.form.contract1
        // })
        params[0].where.push({
          key: '',
          filterType: "ContractNum",
          value: this.state.form.contract1
        })

      } else {
        message.warning('合同编号格式有误');
        this.setState({
          loading: false,
          inSearchOf: false,
        })
        return
      }
    } else if (this.state.form.contract2 != null && this.state.form.contract2 != "") {
      // 如果不满足两个输入框输入条件 判断输入框1是否有值
      let pattern = /^[A-Za-z]{1}(?![0-9]+$)(?![A-Za-z]+$)[0-9A-Za-z]*(-)?[0-9]*$/;
      if (pattern.test(this.state.form.contract2)) {
        // params.push(new CamlParam("Title", this.state.form.contract2, SPDataType.Text, CAMLCompare.Contains));
        // params.push({
        //   item: 'Title',
        //   text: this.state.form.contract2,
        //   type: "indexOf"
        // })

        // params[0].where.push({
        //   key: 'Title',
        //   filterType: "Contains",
        //   value: this.state.form.contract2
        // })
        params[0].where.push({
          key: '',
          filterType: "ContractNum",
          value: this.state.form.contract2
        })

      } else {
        message.warning('合同编号格式有误');
        this.setState({
          loading: false
        })
        return
      }
    }

    // 审查担当
    if ((this.state.form.list != undefined && this.state.form.list != null && this.state.form.list.length != 0) || (this.state.form.personreview != undefined && this.state.form.personreview != null && this.state.form.personreview.length != 0)) {
      // this.fuzzy("ReviewOnID", this.state.form.personreview, "Number", "", "")
      // let array = []

      for (let i = 0; i < this.state.form.personreview.length; i++) {
        // params.push(new CamlParam("ReviewOnID", this.state.form.list[i].key, SPDataType.Text, CAMLCompare.Contains));
        // array.push(this.state.form.list[i].key)
        params[0].where.push({
          key: 'ReviewOnID',
          filterType: "Contains",
          value: this.state.form.personreview[i].replace("-历史", "")
        })

      }

      // params.push({
      //   item: 'ReviewOnID',
      //   text: array,
      //   type: "queryId"
      // })
      // params.push(new CamlParam("ReviewOnID", this.state.form.personreview, SPDataType.Number, CAMLCompare.Eq));
    }

    if (this.state.form.dateOf != "" && this.state.form.dateOf != null) {
      // 2022-10-20T00:00:00Z
      let size = this.state.form.dateOf
      let size1 = this.state.form.dateOf1
      // params.push(new CamlParam("Created", size, SPDataType.DateTime, CAMLCompare.Geq));//我这里用的大于等于，你根据你实际情况来

      params[0].where.push({
        key: 'Created',//属性名称
        filterType: "Ge",//检索方式
        value: size//检索的值
      })
      params[0].where.push({
        key: 'Created',
        filterType: "Le",
        value: size1
      })
    }

    if(text = "检索"){
      let form = this.state.form;
      // 
      
      
      if (form.personreview == undefined) {
        localStorage.setItem('searchForm', JSON.stringify(form));
      }else{
        // localStorage.setItem('searchFormList', JSON.stringify(form.list));
        form.list = [];
        localStorage.setItem('searchForm', JSON.stringify(form));
      }
    }

    //结束日期
    // if (this.state.form.dateOf1 != "" && this.state.form.dateOf1 != null) {
    //   let size = this.state.form.dateOf1
    //   params.push(new CamlParam("Created", size, SPDataType.DateTime, CAMLCompare.Leq));//我这里用的小于于等于，你根据你实际情况来
    // }
    // 
    this.theQuery(params, isBack)
  }
  //弹框确定
  handleOk = () => {
    this.setState({
      confirmLoading: true,
    });
    setTimeout(() => {
      this.setState({
        visible: false,
        confirmLoading: false,
      });
    }, 2000);
  };
  //弹框取消
  handleCancel = () => {
    fromData[18].value = undefined
    fromData[20].value = undefined
    fromData[22].value = undefined
    // this.state.form.dateOf2 = ""
    // this.state.form.dateOf3 = ""
    this.setState({
      visible: false,
    });
  };

  // 输入框改变赋值
  change(e, key) {
    this.setState({
      form: {
        ...this.state.form,
        [key]: e.target.value
      }
    })
  }

  // 下拉框改变赋值
  handleSelectChanges(e, v, key) {
    var array = []
    var arrays = []
    v.forEach(element => {
      array.push(element.key)
      arrays.push(`${element.props.value}#${element.props.children}`)
    });
    this.setState({
      form: {
        ...this.state.form,
        reviewOn: array.join(","),
        reviewOnxuans: arrays.join(';'),
        [key]: e,
        "list": v,
      }
    })
  }

  //时间 转换 时间戳 比较区间
  isMiddle = (aa, bb, cc) => {
    var dateBegin = new Date(aa); //将-转化为/，使用new Date
    var dateEnd = new Date(bb); //将-转化为/，使用new Date
    var dateNow = new Date(cc); //获取当前时间
    var dateBeginNew = dateBegin.getTime();
    var dateEndNew = dateEnd.getTime();
    var dateNowNew = dateNow.getTime();
    let num = dateBeginNew
    let num1 = dateEndNew
    let num2 = dateNowNew
    if (num2 >= num && num2 <= num1) {
      return true
    } else {
      return false
    }
  }

  // 获取日期
  onChangeRangeDate = (value, dateString) => {
    
    this.setState({
      form: {
        ...this.state.form,
        "dateOf": dateString[0] ? dateString[0] + ' 00:00:00' : '',
        "dateOf1": dateString[1] ?  dateString[1] + ' 23:59:59' : ''
      }
    })

  }

  // 获取日期
  onChangeRangeDate1 = (value, dateString) => {
    this.setState({
      form: {
        ...this.state.form,
        "dateOf2": dateString[0] ? dateString[0] + ' 00:00:00' : '',
        "dateOf3": dateString[1] ? dateString[1] + ' 23:59:59' : ''
      }
    })
  }


  loading = false
  public render(): React.ReactElement {
    const { getFieldDecorator } = this.props.form;
    const { visible, confirmLoading } = this.state;
    let defaultDateValue = {};
    if(this.state.form.dateOf != "" && this.state.form.dateOf1 != ""){
      
      defaultDateValue = {
        initialValue: [ // 默认日期
        moment(this.state.form.dateOf, dateFormat),
        moment(this.state.form.dateOf1, dateFormat),
      ],
      };
    }
    return (
      <div className='box'>
        <Spin  spinning={this.state.loading}>
        <div className="box_content">
          <div className="box_top">
            <Row type="flex" justify="end">
              {
                isHavePermission('SearchExportContract/moresearch') ? <Col><Button type="primary" className="Button_1" onClick={this.advanced}>高级检索</Button></Col> : null
              }
              {
                isHavePermission('SearchExportContract/searchcontract') ? <Col><Button type="primary" onClick={() => { this.retrieve("检索") }}>检索编号</Button></Col> : null
              }
              {
                isHavePermission('SearchExportContract/searchdraft') ? <Col><Button type="primary" onClick={() => { this.retrieve("草稿") }}>检索草稿</Button></Col> : null
              }
              {
                isHavePermission('SearchExportContract/searchabandon') ? <Col><Button type="primary" className="Button_2" onClick={() => { this.retrieve("废弃") }}>检索作废</Button></Col> : null
              }
              {
                isHavePermission('SearchExportContract/petitionfilesearch') ? <Col><Button type="primary" onClick={() => { this.noFile() }}>无文件检索</Button></Col>  : null
              }
              {
                  isHavePermission('SearchExportContract/exportcsv') ?  <Col><div className="Button_2_1" style={{color: '#fff',cursor: 'pointer'}} onClick={() => this.setState({ExportCsvVisible: true},() => this.exportCsv())}>
                    导出CSV
                     {/* <ExportCsv className="custom" exportData={this.state.exportData} ></ExportCsv> */}

                  </div></Col> : null
                }
              {/* <Col>
                {
                  isHavePermission('SearchExportContract/petitionfilesearch') ? <Button type="primary" onClick={() => { this.retrieve("申请书") }}>申请书文件检索</Button> : null
                }
              </Col>
              <Col>
                {
                  isHavePermission('SearchExportContract/contractfilesearch') ? <Button type="primary" onClick={() => { this.retrieve("合同文件") }}>合同文件检索</Button> : null
                }
              </Col> */}
            </Row>
            <div style={{ height: 16, width: 100 }}></div>
            <Row type="flex" justify="space-between">
              <Col span={7}>
                <Form.Item label="合同编号" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} labelAlign="left" >
                  <Input.Group compact>
                    <Input style={{ width: '45%', marginRight: 0, textTransform: 'uppercase' }} placeholder="请输入"
                      onChange={(event) => { this.change(event, "contract1") }}
                      value={this.state.form.contract1} />
                    <Input
                      className="site-input-split"
                      style={{
                        width: '10%',
                        background: 'white',
                        // borderLeft: 0,
                        // borderRight: 0,
                        pointerEvents: 'none',
                        border: 'none',
                      }}
                      placeholder="~"
                      disabled
                    />
                    <div></div>
                    <Input
                      className="site-input-right"
                      style={{
                        width: ' 45%',
                      }}
                      placeholder="请输入"
                      onChange={(event) => { this.change(event, "contract2") }}
                      value={this.state.form.contract2}
                    />
                  </Input.Group>
                </Form.Item>
              </Col>
              <Col span={7}>
                <Form.Item label="创建日期" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} labelAlign="left" >
                  {
                    getFieldDecorator('data1', defaultDateValue)(<RangePicker
                      onChange={this.onChangeRangeDate}
                      style={{ width: '100%' }}
                      format={"YYYY-MM-DD"}
                      placeholder={['选择开始日期', '选择结束日期']}
                    />)
                  }
                </Form.Item>
              </Col>
              <Col span={7}>
                <Form.Item label="合同名称" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} labelAlign="left" >
                  <Input
                    allowClear
                    className="site-input-right"
                    style={{
                      width: '100%',
                    }}
                    placeholder="请输入"
                    onChange={(event) => { this.change(event, "contractName") }}
                    value={this.state.form.contractName}
                  />
                </Form.Item>
              </Col>
              <Col span={7} >
                <Form.Item label="我方" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} labelAlign="left" >
                  <Select
                    allowClear
                    style={{
                      width: '100%',
                    }}
                    onChange={(event) => { this.handleSelectChange(event, "min") }}
                    placeholder="请选择"
                    value={this.state.form.min}
                  >
                    {
                      this.state.weList.map(element => {
                        return <Option value={element} key={element}>{element}</Option>
                      })
                    }
                  </Select>
                  {/* <Input
                    className="site-input-right"
                    style={{
                      width: '100%',
                    }}
                    placeholder="请输入"
                    onChange={(event) => { this.change(event, "min") }}
                    value={this.state.form.min}
                  /> */}
                </Form.Item>
              </Col>
              <Col span={7}>
                <Form.Item label="相对方" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} labelAlign="left" >
                  <Input
                    allowClear
                    className="site-input-right"
                    style={{
                      width: '100%',
                    }}
                    placeholder="请输入"
                    value={this.state.form.otherSide}
                    onChange={(event) => { this.change(event, "otherSide") }}
                  />
                </Form.Item>
              </Col>
              <Col span={7}>
                <Form.Item label='审查担当' labelAlign="left" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
                  <Select mode='multiple' placeholder="请选择" allowClear style={{ width: '100%' }} value={this.state.form.personreview}
                    onChange={(event, value) => { this.handleSelectChanges(event, value, "personreview") }} maxTagCount={2}>
                    {
                      this.state.personreviewList.map(element => {
                        return <Option value={element.username} key={element.ID}>{element.username}</Option>
                      })
                    }
                  </Select>
                </Form.Item>
              </Col>
            </Row>
          </div>
          <div style={{ height: '24px' }}></div>
          <div className="box_toble">
            <ConfigProvider locale={this.state.local}>
              <Table columns={this.columns} dataSource={this.state.data}
                
                pagination={{
                  hideOnSinglePage: false,
                  total: this.state.totalnum,
                  showSizeChanger: true,
                  showQuickJumper: true,
                  defaultCurrent: 1,
                  current: this.state.pager.current,
                  onShowSizeChange: (page, pageSize?) => {
                    this.setState({
                      pager: {
                        current: page,
                        size: pageSize
                      }
                    }, () => this.getData())
                  },
                  onChange: (page, pageSize?) => {
                    this.setState({
                      pager: {
                        current: page,
                        size: pageSize
                      }
                    }, () => this.getData())
                  },
                  showTotal: function (total) {
                    return `总共有 ${total} 条数据`;
                  }
                }} />
            </ConfigProvider>
          </div>
          <Modal
            title="导出CSV"
            visible={this.state.ExportCsvVisible}
            onCancel={() => this.setState({ExportCsvVisible: false}, () => dynamicsService.setAbort())}
            maskClosable={false}
            footer={null}
            centered
            destroyOnClose={true}
          >
            {
              this.state.exportData.isLoading ? <div className="spin-text">正在准备数据 <span className="dot-ani"></span></div> : <div className="export_btn" style={{display: 'flex'}}>一共有<span>{this.state.exportData.data.length}</span>条数据，<ExportCsv className="custom" exportData={this.state.exportData} ></ExportCsv></div>
            }
          </Modal>
          <Modal
            destroyOnClose={true}
            visible={visible}
            onCancel={this.handleCancel}
            closable={false}
            footer={null}
            width={'63%'}
          >
            <Form onSubmit={this.handleSubmit} layout='inline' >
              <Row>
                {
                  fromData.map((item, index) => {
                    // type 为 date 日期格式需要强制转化为 moment 格式
                    item.value = item.type == 'date' ? item.value == null ? null : moment(item.value, 'YYYY-MM-DD') : item.value;
                    // item.value = item.type == 'date' ? moment(item.value, 'YYYY-MM-DD') : item.value;
                    return (
                      <Col span={11} offset={index % 2 == 0 ? 0 : 2}>
                        <Form.Item
                          key={index}
                          {...formItemLayout}
                          label={item.text}
                          style={{ display: 'flex', marginTop: '15px' }}
                        >
                          {getFieldDecorator(item.field, {
                            initialValue: item.value,
                            rules: [{
                              required: item.required,
                              message: item.errorMessage
                            }],
                          })(
                            this.switchItem(item)
                          )}
                        </Form.Item>
                      </Col>

                    )
                  })
                }
              </Row>
              <div style={{ height: '24px' }}></div>
              <Row>
                <Col span={3} offset={9}>
                  <Form.Item>
                    <Button type="primary" style={{ padding: ' 0 24px' }} onClick={this.handleSubmit}>检索</Button>
                  </Form.Item>
                </Col>
                <Col span={3}>
                  <Form.Item>
                    <Button type="default" style={{ padding: ' 0 24px' }} onClick={this.handleCancel}>取消</Button>
                  </Form.Item>
                </Col>
              </Row>
            </Form>
          </Modal>

          {/* 非法务部查看详情数据 */}
          <Modal
            visible={this.state.seeDetailsVisible}
            closable={true}
            footer={null}
            width={'63%'}
            destroyOnClose={true}
            onCancel = {() => this.detailsClose()}
          >
            <Form {...layout} name='login'>
            <Row type="flex" justify="start">
              <Col span={11}>
                <Form.Item label='合同编号' labelAlign="right">
                  <Input disabled allowClear placeholder="请输入" value={this.state.detailform.Title} />
                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label='语言' labelAlign="right">
                  <Input disabled allowClear placeholder="请输入内容" value={this.state.detailform.Language} />
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label='法务受理日' labelAlign="right">
                  <Input disabled allowClear placeholder="请输入内容" value={this.state.detailform.AcceptTime} />

                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label='问题' labelAlign="right">
                  <Select
                    allowClear
                    placeholder="请选择"
                    value={this.state.detailform.Problem}
                    disabled
                  >
                    {
                      this.state.problemList.map(element => {
                        return <Option value={element.ID} key={element.Title}>{element.Title}</Option>
                      })
                    }
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label='法务最后回答日' labelAlign="right">
                <Input disabled allowClear placeholder="请输入内容" value={this.state.detailform.LastAnswerTime} />
                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label='合同性质' labelAlign="right">
                  <Select
                    allowClear
                    placeholder="请选择内容"
                    disabled
                    value={this.state.detailform.ContractNatureID}
                  >
                    {
                      this.state.natureList.map(element => {
                        return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label='合同名称' labelAlign="right" >
                 
                  <Input allowClear disabled placeholder="请输入内容" value={this.state.detailform.ContractName}  />
                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label='合同期限' labelAlign="right">
                  <Select
                    allowClear
                    placeholder="请选择内容"
                    disabled
                    value={this.state.detailform.ContractDeadlineID}
                  >
                    {
                      this.state.termList.map(element => {
                        return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label='关键词1' labelAlign="right">
                  <Input disabled allowClear placeholder="请输入内容" value={this.state.detailform.Keyword1} />
                </Form.Item>
              </Col>


              <Col span={11} >
                <Form.Item label='合同重要性' labelAlign="right">
                  <Select
                    allowClear
                    placeholder="请选择内容"
                    disabled
                    value={this.state.detailform.ContractSignificanceID}
                  >
                    {
                      this.state.importanceList.map(element => {
                        return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label='关键词2' labelAlign="right">
                  <Input disabled allowClear placeholder="请输入内容" value={this.state.detailform.Keyword2} />
                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label='合同修改性质' labelAlign="right">
                  <Select
                    allowClear
                    mode='multiple'
                    placeholder="请选择内容"
                    disabled
                    value={this.state.detailform.ContactEditNature}
                    maxTagCount={4}
                  >
                    {
                      this.state.modificationList.map(element => {
                        return <Option value={element.Title} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select>
                </Form.Item>
              </Col>


              <Col span={11}>
                <Form.Item label='我方' labelAlign="right">
                  <Input disabled allowClear placeholder="请输入内容" value={this.state.detailform.Our} />
                  
                </Form.Item>
              </Col>


              <Col span={11} >
                <Form.Item label='资质' labelAlign="right">
                <Input disabled allowClear placeholder="请输入内容" value={this.state.detailform.Qualifications} />
             
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label='相对方' labelAlign="right">
                  <Input allowClear disabled placeholder="请输入内容" value={this.state.detailform.Counterparty}  />
                  
                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label='审核意见书' labelAlign="right">
                  <Select
                    allowClear
                    placeholder="请选择"
                    disabled
                    value={this.state.detailform.HasReviewOpinion}
                  >
                    <Option value='有' >有</Option>
                    <Option value='无' >无</Option>
                  </Select>
                </Form.Item>
              </Col>


              <Col span={11}>
                <Form.Item label='社内依赖者名' labelAlign="right">
                  <Input allowClear placeholder="请输入内容" disabled value={this.state.detailform.RelierName}
                   />
                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label='律师审查' labelAlign="right">
                  <Select
                    allowClear
                    placeholder="请选择"
                    disabled
                    value={this.state.detailform.LawyerReviewID}
                  >
                    {
                      this.state.LawyerList.map(element => {
                        return <Option value={element.ID} key={element.ID}>{element.Title}</Option>
                      })
                    }
                  </Select>
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label='所属公司' labelAlign="right">
                  <Input
                    allowClear
                    disabled
                    value={this.state.detailform.BelongsCompany}
                    placeholder="请输入内容"
                  >

                  </Input>
                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label='决裁编号' labelAlign="right">
                  <Input allowClear disabled value={this.state.detailform.RuleNumber} placeholder='请输入' />
                </Form.Item>
              </Col>


              <Col span={11}>
                <Form.Item label='所属部门' labelAlign="right">
                  <Input
                    allowClear
                    disabled
                    value={this.state.detailform.BelongsDepartment}
                    placeholder="请输入内容"
                  >

                  </Input>
                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label="审查担当">
                  <Input.Group compact>
                  <Input
                    allowClear
                    disabled
                    value={this.state.detailform.reviewOnxuan}
                    placeholder="请输入内容"
                  >

                  </Input>
                    {/* <Select allowClear mode='multiple' disabled placeholder="请选择" style={{ width: '35%' }} value={this.state.detailform.reviewOnxuan} maxTagCount={1}>
                      {
                        this.state.personreviewList.map(element => {
                          return <Option value={element.ID} key={element.Title}>{element.Title}</Option>
                        })
                      }
                    </Select> */}
                  </Input.Group>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label='其他' labelAlign="right">
                  <Input allowClear placeholder="请输入内容" disabled  value={this.state.detailform.Other} />
                </Form.Item>
              </Col>

              <Col span={11} >
                <Form.Item label='文件保存' labelAlign="right">

                  {/* <Input allowClear value={this.state.form.file} onClick={this.getFilds} readOnly /> */}
                  <Input allowClear value={this.state.detailform.FileAddress}  readOnly />

                </Form.Item>
              </Col>





            </Row>

          </Form>
          </Modal>
        </div>
        </Spin>
        
        {/* <button onClick={this.handleClick}>{children}</button> */}
      </div>

    );
  }
  async exportCsv() {
    this.setState({
      exportData: {
        ...this.state.exportData,
        data: [],
        isLoading: true
      }
    })

    let filter = this.state.filter;
    if (filter.length == 0) { // 如果是刚进来的页面，默认检索有效的数据
      filter = [
        {
          logic: "and",
          where: [
            {
              key: 'ContractStatus',
              filterType: "Eq",
              value: "有效"
            }
          ]
        }
      ];
    }   

    let Naturcontract = await Api._getPaged({ Guid: ListGUID.StandingBook, PageSize: 100000, PageIndex: 1, FilterL: filter });
    // let userList: any = []
    // userList = JSON.parse(localStorage.getItem('usersList'));
    // 
    if (Naturcontract && Naturcontract.data && Naturcontract.data.length > 0) {
      for (let i = 0; i < Naturcontract.data.length; i++) {
        // let currentUser = []
        // if(Naturcontract.data[i].AuthorId) {
        //   currentUser = userList.filter(i => i.Id === Naturcontract.data[i].AuthorId);
        // }

        // Naturcontract.data[i].Author = currentUser.length > 0 ? currentUser[0].Title : '';
        Naturcontract.data[i].Created = Naturcontract.data[i].Created ? moment(Naturcontract.data[i].Created).format("YYYY-MM-DD") : '';
        Naturcontract.data[i].AcceptTime = Naturcontract.data[i].AcceptTime ? moment(Naturcontract.data[i].AcceptTime).format("YYYY-MM-DD") : ''
        Naturcontract.data[i].LastAnswerTime = Naturcontract.data[i].LastAnswerTime ? moment(Naturcontract.data[i].LastAnswerTime).format("YYYY-MM-DD")　: ''
      }
      this.setState({
        exportData: {
          ...this.state.exportData,
          data: Naturcontract && Naturcontract.data ? Naturcontract.data : [],
          isLoading: false
        }
      })
    }

    
  }
  async getData() {
    // SEMS2016013-1
    // 
    
    localStorage.setItem('PageIndex', JSON.stringify(this.state.pager.current)); //设置页码

    let filter = this.state.filter;
    if (filter.length == 0) { // 如果是刚进来的页面，默认检索有效的数据
      filter = [
        {
          logic: "and",
          where: [
            {
              key: 'ContractStatus',
              filterType: "Eq",
              value: "有效"
            }
          ]
        }
      ];
    }    
    
    this.setState({
      loading: true,
      data: [],
      totalnum: 0
    })
    let Naturcontract = await Api._getPaged({
      Guid: ListGUID.StandingBook,
      PageSize: this.state.pager.size,
      PageIndex: this.state.pager.current,
      FilterL: filter
    });
    // let Naturcontract = [];
    // let userList: any = []
    // userList = JSON.parse(localStorage.getItem('usersList'));
    if(Naturcontract.data) {
      Naturcontract.data.forEach(async item => {
        // let currentUser = userList.filter(i => i.Id === item.AuthorId);
        // item.Author = currentUser.length > 0 ? currentUser[0].Title : '';
        item.Created = item.Created ? moment(item.Created).format("YYYY-MM-DD") : '';
        item.AcceptTime = item.AcceptTime ? moment(item.AcceptTime).format("YYYY-MM-DD") : ''
        item.LastAnswerTime = item.LastAnswerTime ? moment(item.LastAnswerTime).format("YYYY-MM-DD") : ''

      });
      this.setState({
        // allData: Naturcontract.data,
        data: Naturcontract.data,
        // totalnum: Naturcontract.length,
        totalnum: Naturcontract.Total,
        loading: false,
        inSearchOf: false
      })
    } else {
      this.setState({
        loading: false,
        inSearchOf: false
      })
    }
    
  }
  //合同性质 合同期限 合同重要性 律师审查 审查担当  公司设置  问题 部门列表
  public async getTest() {
    // let Companysettings = await Api._getModel({ Guid: ListGUID.Companies });
    let Companysettings = JSON.parse(sessionStorage.getItem('userDataPer')).ContractWindowCompany && JSON.parse(sessionStorage.getItem('userDataPer')).ContractWindowCompany.length > 0 ? JSON.parse(sessionStorage.getItem('userDataPer')).ContractWindowCompany : JSON.parse(sessionStorage.getItem('userDataPer')).PermissionCompany
    // let userRoleName = JSON.parse(sessionStorage.getItem('userRoleName'))
   
    // if(userRoleName) {
    //   let roleArr = userRoleName.split(',');
    //   let arr = Companysettings.filter(i => roleArr.includes(i.Title))
    //   
    //   Companysettings = arr.length > 0 ? arr : Companysettings
    // }
    // 
    // 表格loading打开
    // this.setState({
    //   loading: true
    // })

    let Person = await Api._getModel({ Guid: ListGUID.ReviewOn });
    const userList = JSON.parse(localStorage.getItem('usersList'));
    //
    Person.forEach(async item => {
      item.username = item.Title
      if (item.ReviewUserId != null) {
        // let informationid = await Api.GetUserById(item.ReviewUserId)
        let informationid = userList.filter(i => i.id === item.ReviewUserId)
        if (informationid && informationid.length > 0) {
          item.Title = informationid.Title
        }
      }
      return
    });
    let historyReviewOn = Person.filter(i => i.Title.includes('-历史'));
    let nowReviewOn = Person.filter(i => !i.Title.includes('-历史'))
    Person = [...nowReviewOn, ...historyReviewOn];
    // let Naturcontract = await Api._getPaged({ Guid: ListGUID.StandingBook, PageSize: this.state.pager.size,PageIndex: this.state.pager.current });
    // Naturcontract = await Api._getPermissionData(ListGUID.StandingBook, Naturcontract)

    // let count = 0
    // if (Naturcontract.length == 0) {
    //   this.exportData.headers = [//表头 key 对应data的属性
    //     { label: "合同编号", key: "Title" },
    //     { label: "法务受理日", key: "AcceptTime" },
    //     { label: "法务最后回答日", key: "LastAnswerTime" },
    //     { label: "合同名称", key: "ContractName" },
    //     { label: "关键词1", key: "Keyword1" },
    //     { label: "关键词2", key: "Keyword2" },
    //     { label: "我方", key: "Our" },
    //     { label: "相对方", key: "Counterparty" },
    //     { label: "社内依赖者名", key: "RelierName" },
    //     { label: "所属公司", key: "BelongsCompany" },
    //     { label: "所属部门", key: "BelongsDepartment" },
    //     { label: "语言", key: "Language" },
    //     { label: "问题", key: "Contractualproblems" },
    //     { label: "合同性质", key: "ContractNature" },
    //     { label: "合同期限", key: "ContractDeadline" },
    //     { label: "合同重要性", key: "ContractSignificance" },
    //     { label: "合同修改性质", key: "ContactEditNature" },
    //     { label: "资质", key: "Qualifications" },
    //     { label: "审核意见书", key: "HasReviewOpinion" },
    //     { label: "律师审查", key: "ContractLawyerReview" },
    //     { label: "决裁编号", key: "RuleNumber" },
    //     { label: "文件保存", key: "FileAddress" },
    //     { label: "其它", key: "Other" },
    //     { label: "审查担当", key: "ReviewOnID" },
    //     { label: "创建者", key: "Author" },
    //     { label: "创建时间", key: "Created" },
    //   ],
    //     this.exportData.data = Naturcontract
    //   //
    //   setTimeout(() => {
    //     this.setState({
    //       data: Naturcontract,
    //       personreviewList: Person,
    //       totalnum: Naturcontract.length,
    //       loading: false,
    //       inSearchOf: false,
    //       weList: Companysettings,

    //     })
    //   }, 100)
    //   return
    // }

    // let userList: any = []
    // userList = JSON.parse(localStorage.getItem('usersList'))

    // Naturcontract.forEach(async element => {



    //   if( element.FileAddress != null){
    //     element.FileAddress = element.FileAddress.substr(0, element.FileAddress.length - 1);
    //   }

    //   for (let i = 0; i < userList.length; i++) {
    //     if (userList[i].Id == element.AuthorId) {
    //       element.Author = userList[i].Title
    //     }
    //   }
    //   element.Created = new Date(element.Created).getFullYear() + '-' + (new Date(element.Created).getMonth() + 1) + '-' + new Date(element.Created).getDate()
    //   if (element.AcceptTime != null) {
    //     element.AcceptTime = new Date(element.AcceptTime).getFullYear() + '-' + (new Date(element.AcceptTime).getMonth() + 1) + '-' + new Date(element.AcceptTime).getDate()
    //   } else {
    //     element.AcceptTime = ''
    //   }
    //   if (element.LastAnswerTime != null) {
    //     element.LastAnswerTime = new Date(element.LastAnswerTime).getFullYear() + '-' + (new Date(element.LastAnswerTime).getMonth() + 1) + '-' + new Date(element.LastAnswerTime).getDate()
    //   } else {
    //     element.LastAnswerTime = ''
    //   }
    //   count++
    //   if (Naturcontract.length == count) {
    //     this.exportData.headers = [//表头 key 对应data的属性
    //       { label: "合同编号", key: "Title" },
    //       { label: "法务受理日", key: "AcceptTime" },
    //       { label: "法务最后回答日", key: "LastAnswerTime" },
    //       { label: "合同名称", key: "ContractName" },
    //       { label: "关键词1", key: "Keyword1" },
    //       { label: "关键词2", key: "Keyword2" },
    //       { label: "我方", key: "Our" },
    //       { label: "相对方", key: "Counterparty" },
    //       { label: "社内依赖者名", key: "RelierName" },
    //       { label: "所属公司", key: "BelongsCompany" },
    //       { label: "所属部门", key: "BelongsDepartment" },
    //       { label: "语言", key: "Language" },
    //       { label: "问题", key: "Contractualproblems" },
    //       { label: "合同性质", key: "ContractNature" },
    //       { label: "合同期限", key: "ContractDeadline" },
    //       { label: "合同重要性", key: "ContractSignificance" },
    //       { label: "合同修改性质", key: "ContactEditNature" },
    //       { label: "资质", key: "Qualifications" },
    //       { label: "审核意见书", key: "HasReviewOpinion" },
    //       { label: "律师审查", key: "ContractLawyerReview" },
    //       { label: "决裁编号", key: "RuleNumber" },
    //       { label: "文件保存", key: "FileAddress" },
    //       { label: "其它", key: "Other" },
    //       { label: "审查担当", key: "ReviewOnID" },
    //       { label: "创建者", key: "Author" },
    //       { label: "创建时间", key: "Created" },
    //     ],
    //       this.exportData.data = Naturcontract
    //     //
    //     setTimeout(() => {
    //       this.setState({
    //         // data: Naturcontract,
    //         // personreviewList: Person,
    //         // totalnum: Naturcontract.length,
    //         // inSearchOf: false,
    //         allData: Naturcontract,
    //         data: Naturcontract,
    //         personreviewList: Person,
    //         totalnum: Naturcontract.length,
    //         loading: false,
    //         inSearchOf: false,
    //         weList: Companysettings,

    //       })
    //     }, 100)
    //   }
    // });
    var param7 = {
      Guid: ListGUID.ContractReviseNature //修改性质
    };
    let NatureContracts = await Api._getModel(param7);
    fromData[23].options = Person
    fromData[14].options = Companysettings
    // 高级检索
    // 问题
    let Problem = await Api._getModel({ Guid: ListGUID.Question });
    // Problem
    fromData[3].options = Problem
    //合同性质
    let theNature = await Api._getModel({ Guid: ListGUID.ContractNature });
    fromData[5].options = theNature
    // 合同期限
    let timeLimit = await Api._getModel({ Guid: ListGUID.ContractPeriod });
    fromData[7].options = timeLimit
    //合同重要性
    let Contractimportance = await Api._getModel({ Guid: ListGUID.ContractImportance });
    fromData[9].options = Contractimportance
    //律师审查
    let Lawyerreview = await Api._getModel({ Guid: ListGUID.LawerReview });
    fromData[17].options = Lawyerreview
    // 资质
    fromData[13].options = [{ ID: "有", Title: "有" }, { ID: "无", Title: "无" }, { ID: "无需资质", Title: "无需资质" }]
    this.setState({
      personreviewList: Person,
      inSearchOf: false,
      weList: Companysettings,

      problemList: Problem,
      natureList: theNature,
      termList: timeLimit,
      importanceList: Contractimportance,
      modificationList: NatureContracts,
      qualificationsList: [{ ID: "有", Title: "有" }, { ID: "无", Title: "无" }, { ID: "无需资质", Title: "无需资质" }],
      LawyerList: Lawyerreview,
    })
  }

  public async theQuery(params, isBack = 0) {

    if (isBack == 0) {
      this.setState({
        filter: params || [],
        // 检索的时候 是新list 需要把页码重置
        pager: {
          current: 1,
          size: 10
        }
      }, () => {
        this.getData()
      })
    }else{
      this.setState({
        filter: params || [],
        //从详情页返回不重置页码 
      }, () => {
        this.getData()
      })
    }
    // 检索结果的list
    let screenList = []
    // if (params.length == 0) {
    //   //
    //   // allData
    //   this.setState({
    //     loading: false,
    //     inSearchOf: false,
    //     data: this.state.allData,
    //     totalnum: this.state.allData.length,
    //   })
    // } else {
    //   //
    //   // startEnd  开始结束时间
    //   // test  文本
    //   
    //   this.setState({
    //     filter: params
    //   }, () => {
    //     this.getData()
    //   })

    //   // for (let index = 0; index < this.state.allData.length; index++) {
    //   //   let ifs = ""
    //   //   for (let j = 0; j < params.length; j++) {
    //   //     let size = params[j].item + ""
    //   //     let size1 = params[j].item1 + ""
    //   //     let size2 = params[j].item2 + ""
    //   //     let size3 = params[j].item3 + ""
    //   //     let size4 = params[j].item4 + ""
    //   //     if (params.length == j + 1) {
    //   //       if (params[j].type == "title") {
    //   //         // 字符串对比
    //   //         ifs += `${params[j].text.includes(this.state.allData[index][`${size}`])}`
    //   //       } else if (params[j].type == "test") {
    //   //         //  全等于
    //   //         if (this.state.allData[index][`${size}`] == params[j].text) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //       } else if (params[j].type == "startEnd") {
    //   //         // 查询日期区间
    //   //         let dataSize = this.isMiddle(params[j].text, params[j].text1, this.state.allData[index][`${size}`])
    //   //         ifs += `${dataSize}`
    //   //       } else if (params[j].type == "indexOf") {
    //   //         // 模糊搜索
    //   //         // ifs += `${"'" + this.state.allData[index][`${size}`] + "'"}.indexOf(${"'" + params[j].text + "'"}) != -1`
    //   //         // 模糊搜索
    //   //         // ifs += `${"'" + this.state.allData[index][`${size}`] + "'"}.indexOf(${"'" + params[j].text + "'"}) != -1`
    //   //         if (this.state.allData[index][`${size}`].indexOf(params[j].text) != -1) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //       } else if (params[j].type == "contractNo") {
    //   //         // 合同编号搜索
    //   //       } else if (params[j].type == "queryId") {
    //   //         // 审查担当多选查询
    //   //         // 列表选中的数据项
    //   //         //
    //   //         if (this.state.allData[index][`${size}`] != null) {
    //   //           //
    //   //           for (let o = 0; o < params[j].text.length; o++) {
    //   //             // 选中的筛选的选项
    //   //             if (this.state.allData[index][`${size}`].indexOf(params[j].text[o]) != -1) {
    //   //               ifs += `${true}`
    //   //             } else {
    //   //               ifs += `${false}`
    //   //             }

    //   //           }
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //       } else if (params[j].type == "contractNo1") {
    //   //         // 合同编号第一种查询方式
    //   //         if (params[j].text1 == this.state.allData[index][`${size1}`]) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //         if (params[j].text2 == this.state.allData[index][`${size2}`]) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //         if (params[j].text3 >= this.state.allData[index][`${size3}`]) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //         if (params[j].text4 >= this.state.allData[index][`${size4}`]) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //       } else if (params[j].type == "contractNo2") {
    //   //         if (params[j].text1 == this.state.allData[index][`${size1}`]) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //         if (params[j].text2 == this.state.allData[index][`${size2}`]) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //         if (params[j].text3 >= this.state.allData[index][`${size3}`]) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //       } else if (params[j].type == "contractNo3") {
    //   //         if (params[j].text <= this.state.allData[index][`${size}`]) {
    //   //           ifs += `${true}`
    //   //         } else {
    //   //           ifs += `${false}`
    //   //         }
    //   //       }
    //   //     } else {
    //   //       if (params[j].type == "title") {
    //   //         ifs += `${params[j].text.includes(this.state.allData[index][`${size}`])} &&`
    //   //       } else if (params[j].type == "test") {
    //   //         // ifs += `${"'" + params[j].text + '=='+ this.state.allData[index][`${size}`] + "'"} &&`
    //   //         if (this.state.allData[index][`${size}`] == params[j].text) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //       } else if (params[j].type == "startEnd") {
    //   //         let dataSize = this.isMiddle(params[j].text, params[j].text1, this.state.allData[index][`${size}`])
    //   //         ifs += `${dataSize}  &&`
    //   //       } else if (params[j].type == "indexOf") {
    //   //         // 模糊搜索
    //   //         // ifs += `${"'" + params[j].text + "'"}.indexOf(${"'" + this.state.allData[index][`${size}`] + "'"}) != -1 &&`
    //   //         // 模糊搜索
    //   //         // ifs += `${"'" + this.state.allData[index][`${size}`] + "'"}.indexOf(${"'" + params[j].text + "'"}) != -1`
    //   //         if (this.state.allData[index][`${size}`].indexOf(params[j].text) != -1) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //       } else if (params[j].type == "contractNo") {
    //   //         // 合同编号搜索
    //   //       } else if (params[j].type == "queryId") {
    //   //         // 审查担当多选查询
    //   //         // 审查担当多选查询
    //   //         // 列表选中的数据项
    //   //         //
    //   //         if (this.state.allData[index][`${size}`] != null) {
    //   //           //
    //   //           for (let o = 0; o < params[j].text.length; o++) {
    //   //             // 选中的筛选的选项
    //   //             if (this.state.allData[index][`${size}`].indexOf(params[j].text[o]) != -1) {
    //   //               ifs += `${true} &&`
    //   //             } else {
    //   //               ifs += `${false} &&`
    //   //             }

    //   //           }
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //       } else if (params[j].type == "contractNo1") {
    //   //         // 合同编号第一种查询方式
    //   //         if (params[j].text1 == this.state.allData[index][`${size1}`]) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //         if (params[j].text2 == this.state.allData[index][`${size2}`]) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //         if (params[j].text3 >= this.state.allData[index][`${size3}`]) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //         if (params[j].text4 >= this.state.allData[index][`${size4}`]) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //       } else if (params[j].type == "contractNo2") {
    //   //         if (params[j].text1 == this.state.allData[index][`${size1}`]) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //         if (params[j].text2 == this.state.allData[index][`${size2}`]) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //         if (params[j].text3 >= this.state.allData[index][`${size3}`]) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //       } else if (params[j].type == "contractNo3") {
    //   //         if (params[j].text <= this.state.allData[index][`${size}`]) {
    //   //           ifs += `${true} &&`
    //   //         } else {
    //   //           ifs += `${false} &&`
    //   //         }
    //   //       }
    //   //     }
    //   //   }

    //   //   if (ifs.slice(ifs.length - 2, ifs.length) == "&&") {
    //   //     ifs = ifs.substr(0, ifs.length - 2);
    //   //   }

    //   //   //

    //   //   if (
    //   //     eval(ifs)
    //   //   ) {
    //   //     screenList.push(this.state.allData[index])
    //   //     // 固定資産廃棄処分申請（二）
    //   //   }

    //   // }

    //   // if (screenList.length == 0) {
    //   //   setTimeout(() => {
    //   //     this.exportData.headers = [//表头 key 对应data的属性
    //   //       { label: "合同编号", key: "Title" },
    //   //       { label: "法务受理日", key: "AcceptTime" },
    //   //       { label: "法务最后回答日", key: "LastAnswerTime" },
    //   //       { label: "合同名称", key: "ContractName" },
    //   //       { label: "关键词1", key: "Keyword1" },
    //   //       { label: "关键词2", key: "Keyword2" },
    //   //       { label: "我方", key: "Our" },
    //   //       { label: "相对方", key: "Counterparty" },
    //   //       { label: "社内依赖者名", key: "RelierName" },
    //   //       { label: "所属公司", key: "BelongsCompany" },
    //   //       { label: "所属部门", key: "BelongsDepartment" },
    //   //       { label: "语言", key: "Language" },
    //   //       { label: "问题", key: "Contractualproblems" },
    //   //       { label: "合同性质", key: "ContractNature" },
    //   //       { label: "合同期限", key: "ContractDeadline" },
    //   //       { label: "合同重要性", key: "ContractSignificance" },
    //   //       { label: "合同修改性质", key: "ContactEditNature" },
    //   //       { label: "资质", key: "Qualifications" },
    //   //       { label: "审核意见书", key: "HasReviewOpinion" },
    //   //       { label: "律师审查", key: "ContractLawyerReview" },
    //   //       { label: "决裁编号", key: "RuleNumber" },
    //   //       { label: "文件保存", key: "FileAddress" },
    //   //       { label: "其它", key: "Other" },
    //   //       { label: "审查担当", key: "ReviewOnID" },
    //   //       { label: "创建者", key: "Author" },
    //   //       { label: "创建时间", key: "Created" },
    //   //     ],

    //   //       this.exportData.data = screenList

    //   //     this.setState({
    //   //       loading: false,
    //   //       inSearchOf: false,
    //   //       data: screenList,
    //   //       totalnum: screenList.length,
    //   //     })
    //   //     //
    //   //     return
    //   //   }, 500)
    //   // }


    //   // setTimeout(() => {
    //   //   this.exportData.headers = [//表头 key 对应data的属性
    //   //     { label: "合同编号", key: "Title" },
    //   //     { label: "法务受理日", key: "AcceptTime" },
    //   //     { label: "法务最后回答日", key: "LastAnswerTime" },
    //   //     { label: "合同名称", key: "ContractName" },
    //   //     { label: "关键词1", key: "Keyword1" },
    //   //     { label: "关键词2", key: "Keyword2" },
    //   //     { label: "我方", key: "Our" },
    //   //     { label: "相对方", key: "Counterparty" },
    //   //     { label: "社内依赖者名", key: "RelierName" },
    //   //     { label: "所属公司", key: "BelongsCompany" },
    //   //     { label: "所属部门", key: "BelongsDepartment" },
    //   //     { label: "语言", key: "Language" },
    //   //     { label: "问题", key: "Contractualproblems" },
    //   //     { label: "合同性质", key: "ContractNature" },
    //   //     { label: "合同期限", key: "ContractDeadline" },
    //   //     { label: "合同重要性", key: "ContractSignificance" },
    //   //     { label: "合同修改性质", key: "ContactEditNature" },
    //   //     { label: "资质", key: "Qualifications" },
    //   //     { label: "审核意见书", key: "HasReviewOpinion" },
    //   //     { label: "律师审查", key: "ContractLawyerReview" },
    //   //     { label: "决裁编号", key: "RuleNumber" },
    //   //     { label: "文件保存", key: "FileAddress" },
    //   //     { label: "其它", key: "Other" },
    //   //     { label: "审查担当", key: "ReviewOnID" },
    //   //     { label: "创建者", key: "Author" },
    //   //     { label: "创建时间", key: "Created" },
    //   //   ],

    //   //     this.exportData.data = screenList

    //   //   this.setState({
    //   //     loading: false,
    //   //     inSearchOf: false,
    //   //     data: screenList,
    //   //     totalnum: screenList.length,
    //   //   })
    //   //   //
    //   // }, 500)
    // }
  }

  // 无文件检索
  public async theQuery1(params) {
    let file = await Api.GetSiteDocumentFolder(ListGUID.ContractLib)
    

    let array = []
    // return
    this.state.allData.forEach(async element => {

      if (element.FileAddress != null) {
        for (let jay = 0; jay < file.length; jay++) {
          // 
          if (file[jay].FSObjType == 1 && file[jay].FileRef.indexOf(element.FileAddress) != -1 && file[jay].Folder.ItemCount == 0) {
            array.push(element)
          }
        }
      }

    })

    setTimeout(() => {
      this.setState({
        loading: false,
        inSearchOf: false,
        data: array,
        totalnum: array.length,
      })
      //
    }, 500)
  }



}

// 无文件检索
// public async theQuery1(params) {
//   let camlQuery = {
//     ViewXml: ''
//   }
//   //根据年龄字段正排
//   let orderAge: CamlOrderBy = new CamlOrderBy('Created', 'False');
//   let demo = Api.buildCamlXml(params, orderAge);
//   //
//   let Guid = ListGUID.StandingBook //根据条件检索表数据
//   camlQuery.ViewXml = demo
//   let Naturcontract1 = await Api.GetListItemsByCAMLQuery(Guid, camlQuery);

//   Naturcontract1 = await Api._getPermissionData(ListGUID.StandingBook, Naturcontract1)
//   // Naturcontract1.forEach(element => {
//   // });
//   let arr = []
//   if (Naturcontract1.length == 0) {
//     this.exportData.data = Naturcontract1
//     //
//     setTimeout(() => {
//       this.setState({
//         data: Naturcontract1,
//         totalnum: Naturcontract1.length,
//         loading: false,
//         inSearchOf: false,
//       })
//     }, 100)
//     return
//   }
//   let count = 0
//   let userList: any = []
//   userList = JSON.parse(localStorage.getItem('usersList'))
//   Naturcontract1.forEach(async element => {
//     for (let i = 0; i < userList.length; i++) {
//       if (userList[i].Id == element.AuthorId) {
//         element.Author = userList[i].Title
//       }
//     }
//     element.Created = element.Created.slice(0, 10)
//     if (element.AcceptTime != null) {
//       element.AcceptTime = new Date(element.AcceptTime).getFullYear() + '-' + (new Date(element.AcceptTime).getMonth() + 1) + '-' + new Date(element.AcceptTime).getDate()
//     } else {
//       element.AcceptTime = ''
//     }
//     if (element.LastAnswerTime != null) {
//       element.LastAnswerTime = new Date(element.LastAnswerTime).getFullYear() + '-' + (new Date(element.LastAnswerTime).getMonth() + 1) + '-' + new Date(element.LastAnswerTime).getDate()
//     } else {
//       element.LastAnswerTime = ''
//     }

//     if (element.FileAddress != null) {
//       let file = await Api.getFiles(ListGUID.ContractLibRelativeUrl + '/' + element.FileAddress);
//       element.file = file
//       element.dueTime = Date.parse(element.Created);
//     } else {
//       element.file = []
//       element.dueTime = Date.parse(element.Created);
//     }

//     if (element.file.length == 0) {
//       arr.push(element)
//     }
//     count++
//     if (Naturcontract1.length == count) {
//       this.exportData.headers = [//表头 key 对应data的属性
//         { label: "合同编号", key: "Title" },
//         { label: "法务受理日", key: "AcceptTime" },
//         { label: "法务最后回答日", key: "LastAnswerTime" },
//         { label: "合同名称", key: "ContractName" },
//         { label: "关键词1", key: "Keyword1" },
//         { label: "关键词2", key: "Keyword2" },
//         { label: "我方", key: "Our" },
//         { label: "相对方", key: "Counterparty" },
//         { label: "社内依赖者名", key: "RelierName" },
//         { label: "所属公司", key: "BelongsCompany" },
//         { label: "所属部门", key: "BelongsDepartment" },
//         { label: "语言", key: "Language" },
//         { label: "问题", key: "Contractualproblems" },
//         { label: "合同性质", key: "ContractNature" },
//         { label: "合同期限", key: "ContractDeadline" },
//         { label: "合同重要性", key: "ContractSignificance" },
//         { label: "合同修改性质", key: "ContactEditNature" },
//         { label: "资质", key: "Qualifications" },
//         { label: "审核意见书", key: "HasReviewOpinion" },
//         { label: "律师审查", key: "ContractLawyerReview" },
//         { label: "决裁编号", key: "RuleNumber" },
//         { label: "文件保存", key: "FileAddress" },
//         { label: "其它", key: "Other" },
//         { label: "审查担当", key: "ReviewOnID" },
//         { label: "创建者", key: "Author" },
//         { label: "创建时间", key: "Created" },
//       ]
//       setTimeout(() => {
//         arr = arr.sort(function (a, b) {
//           return b.dueTime - a.dueTime;
//         });
//         //
//         this.exportData.data = arr
//         //
//         //
//         this.setState({
//           data: arr,
//           totalnum: arr.length,
//           loading: false,
//           inSearchOf: false,
//         })
//       }, 500)
//     }
//     // return
//   });

// }


export default Form.create()(SearchExportContract);